… | |
… | |
58 | use Compress::LZF; |
58 | use Compress::LZF; |
59 | |
59 | |
60 | use CFPlus; |
60 | use CFPlus; |
61 | use CFPlus::OpenGL (); |
61 | use CFPlus::OpenGL (); |
62 | use CFPlus::Protocol; |
62 | use CFPlus::Protocol; |
|
|
63 | use CFPlus::DB; |
63 | use CFPlus::UI; |
64 | use CFPlus::UI; |
64 | use CFPlus::UI::Inventory; |
65 | use CFPlus::UI::Inventory; |
65 | use CFPlus::UI::SpellList; |
66 | use CFPlus::UI::SpellList; |
66 | use CFPlus::Pod; |
67 | use CFPlus::Pod; |
67 | use CFPlus::MapWidget; |
68 | use CFPlus::MapWidget; |
… | |
… | |
206 | title => "Server Query", |
207 | title => "Server Query", |
207 | child => my $vbox = new CFPlus::UI::VBox, |
208 | child => my $vbox = new CFPlus::UI::VBox, |
208 | ; |
209 | ; |
209 | |
210 | |
210 | my @dialog = my $label = new CFPlus::UI::Label |
211 | my @dialog = my $label = new CFPlus::UI::Label |
211 | max_w => $::WIDTH * 0.4, |
212 | max_w => $::WIDTH * 0.8, |
212 | ellipsise => 0, |
213 | ellipsise => 0, |
213 | text => $prompt; |
214 | text => $prompt; |
214 | |
215 | |
215 | if ($flags & CS_QUERY_YESNO) { |
216 | if ($flags & CS_QUERY_YESNO) { |
216 | push @dialog, my $hbox = new CFPlus::UI::HBox; |
217 | push @dialog, my $hbox = new CFPlus::UI::HBox; |
… | |
… | |
233 | ); |
234 | ); |
234 | |
235 | |
235 | $dialog->grab_focus; |
236 | $dialog->grab_focus; |
236 | |
237 | |
237 | } elsif ($flags & CS_QUERY_SINGLECHAR) { |
238 | } elsif ($flags & CS_QUERY_SINGLECHAR) { |
238 | $dialog->{tooltip} = "#charcreation_focus"; |
|
|
239 | |
|
|
240 | 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) { |
241 | $MESSAGE_WINDOW->show; |
240 | $dialog->{tooltip} = "#charcreation_focus"; |
242 | |
241 | |
243 | unshift @dialog, new CFPlus::UI::Label |
242 | unshift @dialog, new CFPlus::UI::Label |
244 | max_w => $::WIDTH * 0.4, |
243 | max_w => $::WIDTH * 0.8, |
245 | ellipsise => 0, |
244 | ellipsise => 0, |
246 | markup => "\nOr use your keyboard and the text entry below:\n"; |
245 | markup => "\nOr use your keyboard and the text entry below:\n"; |
247 | |
246 | |
248 | unshift @dialog, my $table = new CFPlus::UI::Table; |
247 | unshift @dialog, my $table = new CFPlus::UI::Table; |
249 | |
248 | |
… | |
… | |
261 | $conn->send ("reply d"); |
260 | $conn->send ("reply d"); |
262 | destroy_query_dialog $conn; |
261 | destroy_query_dialog $conn; |
263 | 0 |
262 | 0 |
264 | }, |
263 | }, |
265 | ); |
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 | if ($conn->{chargen_race_title}) { |
|
|
275 | unshift @dialog, new CFPlus::UI::Face |
|
|
276 | face => $conn->{player}{face}, |
|
|
277 | bg => [.2, .2, .2, 1], |
|
|
278 | min_w => 64, |
|
|
279 | min_h => 64, |
|
|
280 | ; |
|
|
281 | } |
|
|
282 | |
|
|
283 | if ($conn->{chargen_race_title}) { |
|
|
284 | unshift @dialog, new CFPlus::UI::Label |
|
|
285 | allign => 1, |
|
|
286 | ellipsise => 0, |
|
|
287 | markup => "<span foreground='#ccccff' size='large'>Race: $conn->{chargen_race_title}</span>", |
|
|
288 | ; |
|
|
289 | } |
266 | |
290 | |
267 | unshift @dialog, new CFPlus::UI::Label |
291 | unshift @dialog, new CFPlus::UI::Label |
268 | max_w => $::WIDTH * 0.4, |
292 | max_w => $::WIDTH * 0.4, |
269 | ellipsise => 0, |
293 | ellipsise => 0, |
270 | markup => (CFPlus::Pod::section_label ui => "chargen_race"), |
294 | markup => (CFPlus::Pod::section_label ui => "chargen_race"), |
… | |
… | |
419 | statusbox => $STATUSBOX, |
443 | statusbox => $STATUSBOX, |
420 | map => $MAP, |
444 | map => $MAP, |
421 | mapmap => $MAPMAP, |
445 | mapmap => $MAPMAP, |
422 | query => \&server_query, |
446 | query => \&server_query, |
423 | |
447 | |
|
|
448 | setup_req => { |
|
|
449 | smoothing => $CFG->{map_smoothing}*1, |
|
|
450 | }, |
|
|
451 | |
424 | sound_play => sub { |
452 | sound_play => sub { |
425 | my ($x, $y, $soundnum, $type) = @_; |
453 | my ($x, $y, $soundnum, $type) = @_; |
426 | |
454 | |
427 | $SDL_MIXER |
455 | $SDL_MIXER |
428 | or return; |
456 | or return; |
… | |
… | |
465 | sub graphics_setup { |
493 | sub graphics_setup { |
466 | my $vbox = new CFPlus::UI::VBox; |
494 | my $vbox = new CFPlus::UI::VBox; |
467 | |
495 | |
468 | $vbox->add (my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 1]); |
496 | $vbox->add (my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 1]); |
469 | |
497 | |
|
|
498 | my $row = 0; |
|
|
499 | |
|
|
500 | $table->add (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "OpenGL Info"); |
|
|
501 | $table->add (1, $row++, new CFPlus::UI::Label valign => 0, fontsize => 0.8, text => CFPlus::OpenGL::gl_vendor . ", " . CFPlus::OpenGL::gl_version, |
|
|
502 | can_events => 1, |
|
|
503 | tooltip => "<tt><span size='8192'>" . (CFPlus::OpenGL::gl_extensions) . "</span></tt>"); |
|
|
504 | |
470 | $table->add (0, 0, new CFPlus::UI::Label valign => 0, align => 1, text => "Video Mode"); |
505 | $table->add (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Video Mode"); |
471 | $table->add (1, 0, my $hbox = new CFPlus::UI::HBox); |
506 | $table->add (1, $row++, my $hbox = new CFPlus::UI::HBox); |
472 | |
507 | |
473 | $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]); |
508 | $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]); |
474 | $hbox->add (my $mode_label = new CFPlus::UI::Label align => 0, valign => 0, height => 0.8, template => "9999x9999"); |
509 | $hbox->add (my $mode_label = new CFPlus::UI::Label align => 0, valign => 0, height => 0.8, template => "9999x9999"); |
475 | |
510 | |
476 | $mode_slider->connect (changed => sub { |
511 | $mode_slider->connect (changed => sub { |
… | |
… | |
478 | |
513 | |
479 | $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value; |
514 | $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value; |
480 | $mode_label->set_text (sprintf "%dx%d", @{$SDL_MODES[$value]}); |
515 | $mode_label->set_text (sprintf "%dx%d", @{$SDL_MODES[$value]}); |
481 | }); |
516 | }); |
482 | $mode_slider->emit (changed => $mode_slider->{range}[0]); |
517 | $mode_slider->emit (changed => $mode_slider->{range}[0]); |
483 | |
|
|
484 | my $row = 1; |
|
|
485 | |
518 | |
486 | $table->add (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fullscreen"); |
519 | $table->add (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fullscreen"); |
487 | $table->add (1, $row++, $FULLSCREEN_ENABLE = new CFPlus::UI::CheckBox |
520 | $table->add (1, $row++, $FULLSCREEN_ENABLE = new CFPlus::UI::CheckBox |
488 | state => $CFG->{fullscreen}, |
521 | state => $CFG->{fullscreen}, |
489 | tooltip => "Bring the client into fullscreen mode.", |
522 | tooltip => "Bring the client into fullscreen mode.", |
… | |
… | |
495 | state => $CFG->{fast}, |
528 | state => $CFG->{fast}, |
496 | tooltip => "Lower the visual quality considerably to speed up rendering.", |
529 | tooltip => "Lower the visual quality considerably to speed up rendering.", |
497 | on_changed => sub { my ($self, $value) = @_; $CFG->{fast} = $value; 0 } |
530 | on_changed => sub { my ($self, $value) = @_; $CFG->{fast} = $value; 0 } |
498 | ); |
531 | ); |
499 | |
532 | |
|
|
533 | $table->add (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "GUI Fontsize"); |
|
|
534 | $table->add (1, $row++, new CFPlus::UI::Slider |
|
|
535 | range => [$CFG->{gui_fontsize}, 0.5, 2, 0, 0.1], |
|
|
536 | tooltip => "The base font size used by most GUI elements that do not have their own setting.", |
|
|
537 | on_changed => sub { $CFG->{gui_fontsize} = $_[1]; 0 }, |
|
|
538 | ); |
|
|
539 | |
|
|
540 | $table->add (1, $row++, new CFPlus::UI::Button |
|
|
541 | expand => 1, align => 0, text => "Apply", |
|
|
542 | tooltip => "Apply the video settings above.", |
|
|
543 | on_activate => sub { |
|
|
544 | video_shutdown (); |
|
|
545 | video_init (); |
|
|
546 | 0 |
|
|
547 | } |
|
|
548 | ); |
|
|
549 | |
500 | $table->add (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Map Scale"); |
550 | $table->add (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Map Scale"); |
501 | $table->add (1, $row++, new CFPlus::UI::Slider |
551 | $table->add (1, $row++, new CFPlus::UI::Slider |
502 | range => [(log $CFG->{map_scale}) / (log 2), -3, 1, 0, 1], |
552 | range => [(log $CFG->{map_scale}) / (log 2), -3, 1, 0, 1], |
503 | tooltip => "Enlarge or shrink the displayed map. Changes are instant.", |
553 | tooltip => "Enlarge or shrink the displayed map. Changes are instant.", |
504 | on_changed => sub { my ($self, $value) = @_; $CFG->{map_scale} = 2 ** $value; 0 } |
554 | on_changed => sub { my ($self, $value) = @_; $CFG->{map_scale} = 2 ** $value; 0 } |
|
|
555 | ); |
|
|
556 | |
|
|
557 | $table->add (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Smoothing"); |
|
|
558 | $table->add (1, $row++, new CFPlus::UI::CheckBox |
|
|
559 | state => $CFG->{map_smoothing}, |
|
|
560 | tooltip => "<b>Map Smoothing</b> tries to make tile borders less square. " |
|
|
561 | . "This increases load on the graphics subsystem and works only with 2.x servers. " |
|
|
562 | . "Changes take effect at next connection only.", |
|
|
563 | on_changed => sub { my ($self, $value) = @_; $CFG->{map_smoothing} = $value; 0 } |
505 | ); |
564 | ); |
506 | |
565 | |
507 | $table->add (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fog of War"); |
566 | $table->add (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fog of War"); |
508 | $table->add (1, $row++, new CFPlus::UI::CheckBox |
567 | $table->add (1, $row++, new CFPlus::UI::CheckBox |
509 | state => $CFG->{fow_enable}, |
568 | state => $CFG->{fow_enable}, |
… | |
… | |
528 | status "Fog of War smoothing requires OpenGL 1.2 or higher" if $CFPlus::OpenGL::GL_VERSION < 1.2; |
587 | status "Fog of War smoothing requires OpenGL 1.2 or higher" if $CFPlus::OpenGL::GL_VERSION < 1.2; |
529 | 0 |
588 | 0 |
530 | } |
589 | } |
531 | ); |
590 | ); |
532 | |
591 | |
533 | $table->add (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "GUI Fontsize"); |
|
|
534 | $table->add (1, $row++, new CFPlus::UI::Slider |
|
|
535 | range => [$CFG->{gui_fontsize}, 0.5, 2, 0, 0.1], |
|
|
536 | tooltip => "The base font size used by most GUI elements that do not have their own setting.", |
|
|
537 | on_changed => sub { $CFG->{gui_fontsize} = $_[1]; 0 }, |
|
|
538 | ); |
|
|
539 | |
|
|
540 | $table->add (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Message Fontsize"); |
592 | $table->add (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Message Fontsize"); |
541 | $table->add (1, $row++, new CFPlus::UI::Slider |
593 | $table->add (1, $row++, new CFPlus::UI::Slider |
542 | range => [$CFG->{log_fontsize}, 0.5, 2, 0, 0.1], |
594 | range => [$CFG->{log_fontsize}, 0.5, 2, 0, 0.1], |
543 | tooltip => "The font size used by the <b>message/server log</b> window only. Changes are instant.", |
595 | tooltip => "The font size used by the <b>message/server log</b> window only. Changes are instant.", |
544 | on_changed => sub { $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = $_[1]); 0 }, |
596 | on_changed => sub { $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = $_[1]); 0 }, |
… | |
… | |
560 | range => [$CFG->{gauge_size}, 0.2, 0.8], |
612 | range => [$CFG->{gauge_size}, 0.2, 0.8], |
561 | tooltip => "Adjust the size of the stats gauges at the bottom right. Changes are instant.", |
613 | tooltip => "Adjust the size of the stats gauges at the bottom right. Changes are instant.", |
562 | on_changed => sub { |
614 | on_changed => sub { |
563 | $CFG->{gauge_size} = $_[1]; |
615 | $CFG->{gauge_size} = $_[1]; |
564 | $GAUGES->{win}->set_size ($WIDTH, int $HEIGHT * $CFG->{gauge_size}); |
616 | $GAUGES->{win}->set_size ($WIDTH, int $HEIGHT * $CFG->{gauge_size}); |
565 | 0 |
|
|
566 | } |
|
|
567 | ); |
|
|
568 | |
|
|
569 | $table->add (1, $row++, new CFPlus::UI::Button |
|
|
570 | expand => 1, align => 0, text => "Apply", |
|
|
571 | tooltip => "Apply the video settings", |
|
|
572 | on_activate => sub { |
|
|
573 | video_shutdown (); |
|
|
574 | video_init (); |
|
|
575 | 0 |
617 | 0 |
576 | } |
618 | } |
577 | ); |
619 | ); |
578 | |
620 | |
579 | $vbox |
621 | $vbox |
… | |
… | |
1092 | : start_game; |
1134 | : start_game; |
1093 | 0 |
1135 | 0 |
1094 | }, |
1136 | }, |
1095 | ); |
1137 | ); |
1096 | |
1138 | |
|
|
1139 | $vbox->add (new CFPlus::UI::FancyFrame |
|
|
1140 | label => "Server Info", |
|
|
1141 | child => ($SERVER_INFO = new CFPlus::UI::Label ellipsise => 0), |
|
|
1142 | ); |
|
|
1143 | |
|
|
1144 | $vbox |
|
|
1145 | } |
|
|
1146 | |
|
|
1147 | sub client_setup { |
|
|
1148 | my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 1]; |
|
|
1149 | |
|
|
1150 | my $row = 0; |
|
|
1151 | |
1097 | $table->add (0, 13, new CFPlus::UI::Label valign => 0, align => 1, text => "Chat Command"); |
1152 | $table->add (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Chat Command"); |
1098 | $table->add (1, 13, my $saycmd = new CFPlus::UI::Entry |
1153 | $table->add (1, $row++, my $saycmd = new CFPlus::UI::Entry |
1099 | text => $CFG->{say_command}, |
1154 | text => $CFG->{say_command}, |
1100 | 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. " |
1155 | 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. " |
1101 | . "Usually you want to enter something like 'say' or 'shout' or 'gsay' here. " |
1156 | . "Usually you want to enter something like 'say' or 'shout' or 'gsay' here. " |
1102 | . "But you could also set it to <b>tell <i>playername</i></b> to only chat with that user.", |
1157 | . "But you could also set it to <b>tell <i>playername</i></b> to only chat with that user.", |
1103 | on_changed => sub { |
1158 | on_changed => sub { |
1104 | my ($self, $value) = @_; |
1159 | my ($self, $value) = @_; |
1105 | $CFG->{say_command} = $value; |
1160 | $CFG->{say_command} = $value; |
1106 | 0 |
1161 | 0 |
1107 | } |
1162 | } |
1108 | ); |
1163 | ); |
1109 | |
1164 | |
1110 | $table->add (0, 14, new CFPlus::UI::Label valign => 0, align => 1, text => "Tip of the day"); |
1165 | $table->add (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Tip of the day"); |
1111 | $table->add (1, 14, my $saycmd = new CFPlus::UI::CheckBox |
1166 | $table->add (1, $row++, new CFPlus::UI::CheckBox |
1112 | state => $CFG->{show_tips}, |
1167 | state => $CFG->{show_tips}, |
1113 | tooltip => "Show the <b>Tip of the day</b> window at startup?", |
1168 | tooltip => "Show the <b>Tip of the day</b> window at startup?", |
1114 | on_changed => sub { |
1169 | on_changed => sub { |
1115 | my ($self, $value) = @_; |
1170 | my ($self, $value) = @_; |
1116 | $CFG->{show_tips} = $value; |
1171 | $CFG->{show_tips} = $value; |
1117 | 0 |
1172 | 0 |
1118 | } |
1173 | } |
1119 | ); |
1174 | ); |
1120 | |
1175 | |
1121 | $vbox->add (new CFPlus::UI::FancyFrame |
1176 | $table->add (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Messages Window Size"); |
1122 | label => "Server Info", |
1177 | $table->add (1, $row++, my $saycmd = new CFPlus::UI::Entry |
1123 | child => ($SERVER_INFO = new CFPlus::UI::Label ellipsise => 0), |
1178 | text => $CFG->{logview_max_par}, |
|
|
1179 | tooltip => "This is maximum number of messages remembered in the <b>Messages</b> window. If the server " |
|
|
1180 | . "sends more messages than this number, older messages get removed to save memory and " |
|
|
1181 | . "computing time. A value of <b>0</b> disables this feature, but that is not recommended.", |
|
|
1182 | on_changed => sub { |
|
|
1183 | my ($self, $value) = @_; |
|
|
1184 | $LOGVIEW->{max_par} = $CFG->{logview_max_par} = $value*1; |
|
|
1185 | 0 |
|
|
1186 | }, |
1124 | ); |
1187 | ); |
1125 | |
1188 | |
1126 | $vbox |
1189 | $table |
1127 | } |
1190 | } |
1128 | |
1191 | |
1129 | sub message_window { |
1192 | sub message_window { |
1130 | my $window = new CFPlus::UI::Toplevel |
1193 | my $window = new CFPlus::UI::Toplevel |
1131 | name => "message_window", |
1194 | name => "message_window", |
… | |
… | |
1568 | |
1631 | |
1569 | sub show_tip_of_the_day { |
1632 | sub show_tip_of_the_day { |
1570 | # find all tips |
1633 | # find all tips |
1571 | my @tod = CFPlus::Pod::find tip_of_the_day => "*"; |
1634 | my @tod = CFPlus::Pod::find tip_of_the_day => "*"; |
1572 | |
1635 | |
1573 | my $todindex = $CFPlus::DB_STATE->get ("tip_of_the_day"); |
1636 | CFPlus::DB::get state => "tip_of_the_day", sub { |
|
|
1637 | my ($todindex) = @_; |
1574 | $todindex = 0 if $todindex >= @tod; |
1638 | $todindex = 0 if $todindex >= @tod; |
1575 | $CFPlus::DB_STATE->put (tip_of_the_day => $todindex + 1); |
1639 | CFPlus::DB::put state => tip_of_the_day => $todindex + 1, sub { }; |
1576 | |
1640 | |
1577 | # create dialog |
1641 | # create dialog |
1578 | my $dialog; |
1642 | my $dialog; |
1579 | |
1643 | |
1580 | my $close = sub { |
1644 | my $close = sub { |
1581 | $dialog->destroy; |
1645 | $dialog->destroy; |
|
|
1646 | }; |
|
|
1647 | |
|
|
1648 | $dialog = new CFPlus::UI::Toplevel |
|
|
1649 | x => "center", |
|
|
1650 | y => "center", |
|
|
1651 | z => 3, |
|
|
1652 | name => 'tip_of_the_day', |
|
|
1653 | force_w => int $WIDTH * 4/9, |
|
|
1654 | force_h => int $WIDTH * 2/9, |
|
|
1655 | title => "Tip of the day #" . (1 + $todindex), |
|
|
1656 | child => my $vbox = new CFPlus::UI::VBox, |
|
|
1657 | has_close_button => 1, |
|
|
1658 | on_delete => $close, |
|
|
1659 | ; |
|
|
1660 | |
|
|
1661 | $vbox->add (my $viewer = new CFPlus::UI::TextScroller |
|
|
1662 | expand => 1, fontsize => 0.8, padding_x => 4, padding_y => 4); |
|
|
1663 | $viewer->add_paragraph (CFPlus::Pod::as_paragraphs CFPlus::Pod::section_of $tod[$todindex]); |
|
|
1664 | |
|
|
1665 | $vbox->add (my $table = new CFPlus::UI::Table col_expand => [0, 1]); |
|
|
1666 | |
|
|
1667 | $table->add (0, 0, new CFPlus::UI::Button |
|
|
1668 | text => "Close", |
|
|
1669 | 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>.", |
|
|
1670 | on_activate => $close, |
|
|
1671 | ); |
|
|
1672 | |
|
|
1673 | $table->add (2, 0, new CFPlus::UI::Button |
|
|
1674 | text => "Next", |
|
|
1675 | tooltip => "Show the next <b>Tip of the day</b>.", |
|
|
1676 | on_activate => sub { |
|
|
1677 | $close->(); |
|
|
1678 | &show_tip_of_the_day; |
|
|
1679 | }, |
|
|
1680 | ); |
|
|
1681 | |
|
|
1682 | $dialog->show; |
1582 | }; |
1683 | }; |
1583 | |
|
|
1584 | $dialog = new CFPlus::UI::Toplevel |
|
|
1585 | x => "center", |
|
|
1586 | y => "center", |
|
|
1587 | z => 3, |
|
|
1588 | name => 'tip_of_the_day', |
|
|
1589 | force_w => int $WIDTH * 4/9, |
|
|
1590 | force_h => int $WIDTH * 2/9, |
|
|
1591 | title => "Tip of the day #" . (1 + $todindex), |
|
|
1592 | child => my $vbox = new CFPlus::UI::VBox, |
|
|
1593 | has_close_button => 1, |
|
|
1594 | on_delete => $close, |
|
|
1595 | ; |
|
|
1596 | |
|
|
1597 | $vbox->add (my $viewer = new CFPlus::UI::TextScroller |
|
|
1598 | expand => 1, fontsize => 0.8, padding_x => 4, padding_y => 4); |
|
|
1599 | $viewer->add_paragraph (CFPlus::Pod::as_paragraphs CFPlus::Pod::section_of $tod[$todindex]); |
|
|
1600 | |
|
|
1601 | $vbox->add (my $table = new CFPlus::UI::Table col_expand => [0, 1]); |
|
|
1602 | |
|
|
1603 | $table->add (0, 0, new CFPlus::UI::Button |
|
|
1604 | text => "Close", |
|
|
1605 | 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>.", |
|
|
1606 | on_activate => $close, |
|
|
1607 | ); |
|
|
1608 | |
|
|
1609 | $table->add (2, 0, new CFPlus::UI::Button |
|
|
1610 | text => "Next", |
|
|
1611 | tooltip => "Show the next <b>Tip of the day</b>.", |
|
|
1612 | on_activate => sub { |
|
|
1613 | $close->(); |
|
|
1614 | &show_tip_of_the_day; |
|
|
1615 | }, |
|
|
1616 | ); |
|
|
1617 | |
|
|
1618 | $dialog->show; |
|
|
1619 | } |
1684 | } |
1620 | |
1685 | |
1621 | sub sdl_init { |
1686 | sub sdl_init { |
1622 | CFPlus::SDL_Init |
1687 | CFPlus::SDL_Init |
1623 | and die "SDL::Init failed!\n"; |
1688 | and die "SDL::Init failed!\n"; |
… | |
… | |
1703 | font => $FONT_FIXED, |
1768 | font => $FONT_FIXED, |
1704 | fontsize => $::CFG->{log_fontsize}, |
1769 | fontsize => $::CFG->{log_fontsize}, |
1705 | indent => -4, |
1770 | indent => -4, |
1706 | can_hover => 1, |
1771 | can_hover => 1, |
1707 | can_events => 1, |
1772 | can_events => 1, |
|
|
1773 | max_par => $CFG->{logview_max_par}, |
1708 | tooltip => "<b>Server Log</b>. This text viewer contains all the messages sent by the server.", |
1774 | tooltip => "<b>Server Log</b>. This text viewer contains all recent messages sent by the server.", |
1709 | ; |
1775 | ; |
1710 | |
1776 | |
1711 | $SETUP_DIALOG = new CFPlus::UI::Toplevel |
1777 | $SETUP_DIALOG = new CFPlus::UI::Toplevel |
1712 | title => "Setup", |
1778 | title => "Setup", |
1713 | name => "setup_dialog", |
1779 | name => "setup_dialog", |
… | |
… | |
1724 | $SETUP_DIALOG->add ($SETUP_NOTEBOOK = new CFPlus::UI::Notebook expand => 1, debug => 1, |
1790 | $SETUP_DIALOG->add ($SETUP_NOTEBOOK = new CFPlus::UI::Notebook expand => 1, debug => 1, |
1725 | filter => new CFPlus::UI::ScrolledWindow expand => 1, scroll_y => 1); |
1791 | filter => new CFPlus::UI::ScrolledWindow expand => 1, scroll_y => 1); |
1726 | |
1792 | |
1727 | $SETUP_NOTEBOOK->add (Server => $SETUP_SERVER = server_setup, |
1793 | $SETUP_NOTEBOOK->add (Server => $SETUP_SERVER = server_setup, |
1728 | "Configure the server to play on, your username, password and other server-related options."); |
1794 | "Configure the server to play on, your username, password and other server-related options."); |
|
|
1795 | $SETUP_NOTEBOOK->add (Client => client_setup, |
|
|
1796 | "Configure various client-specific settings."); |
1729 | $SETUP_NOTEBOOK->add (Pickup => autopickup_setup, |
1797 | $SETUP_NOTEBOOK->add (Pickup => autopickup_setup, |
1730 | "Configure autopickup settings, i.e. which items you will pick up automatically when walking (or running) over them."); |
1798 | "Configure autopickup settings, i.e. which items you will pick up automatically when walking (or running) over them."); |
1731 | $SETUP_NOTEBOOK->add (Graphics => graphics_setup, |
1799 | $SETUP_NOTEBOOK->add (Graphics => graphics_setup, |
1732 | "Configure the video mode, performance, fonts and other graphical aspects of the game."); |
1800 | "Configure the video mode, performance, fonts and other graphical aspects of the game."); |
1733 | $SETUP_NOTEBOOK->add (Audio => audio_setup, |
1801 | $SETUP_NOTEBOOK->add (Audio => audio_setup, |
… | |
… | |
2034 | if $CONN; |
2102 | if $CONN; |
2035 | }); |
2103 | }); |
2036 | |
2104 | |
2037 | %SDL_CB = ( |
2105 | %SDL_CB = ( |
2038 | CFPlus::SDL_QUIT => sub { |
2106 | CFPlus::SDL_QUIT => sub { |
2039 | Event::unloop -1; |
2107 | exit; |
2040 | }, |
2108 | }, |
2041 | CFPlus::SDL_VIDEORESIZE => sub { |
2109 | CFPlus::SDL_VIDEORESIZE => sub { |
2042 | }, |
2110 | }, |
2043 | CFPlus::SDL_VIDEOEXPOSE => sub { |
2111 | CFPlus::SDL_VIDEOEXPOSE => sub { |
2044 | CFPlus::UI::full_refresh; |
2112 | CFPlus::UI::full_refresh; |
… | |
… | |
2077 | |
2145 | |
2078 | $SIG{INT} = $SIG{TERM} = sub { exit }; |
2146 | $SIG{INT} = $SIG{TERM} = sub { exit }; |
2079 | |
2147 | |
2080 | { |
2148 | { |
2081 | CFPlus::read_cfg "$Crossfire::VARDIR/cfplusrc"; |
2149 | CFPlus::read_cfg "$Crossfire::VARDIR/cfplusrc"; |
|
|
2150 | CFPlus::DB::Server::run; |
|
|
2151 | |
2082 | CFPlus::UI::set_layout ($::CFG->{layout}); |
2152 | CFPlus::UI::set_layout ($::CFG->{layout}); |
2083 | |
2153 | |
2084 | my %DEF_CFG = ( |
2154 | my %DEF_CFG = ( |
2085 | sdl_mode => 0, |
2155 | sdl_mode => 0, |
2086 | width => 640, |
2156 | width => 640, |
2087 | height => 480, |
2157 | height => 480, |
2088 | fullscreen => 0, |
2158 | fullscreen => 0, |
2089 | fast => 0, |
2159 | fast => 0, |
2090 | map_scale => 1, |
2160 | map_scale => 1, |
2091 | fow_enable => 1, |
2161 | fow_enable => 1, |
2092 | fow_intensity => 0.45, |
2162 | fow_intensity => 0.45, |
2093 | fow_smooth => 0, |
2163 | fow_smooth => 0, |
|
|
2164 | map_smoothing => 1, |
2094 | gui_fontsize => 1, |
2165 | gui_fontsize => 1, |
2095 | log_fontsize => 0.7, |
2166 | log_fontsize => 0.7, |
2096 | gauge_fontsize => 1, |
2167 | gauge_fontsize => 1, |
2097 | gauge_size => 0.35, |
2168 | gauge_size => 0.35, |
2098 | stat_fontsize => 0.7, |
2169 | stat_fontsize => 0.7, |
2099 | mapsize => 100, |
2170 | mapsize => 100, |
2100 | say_command => 'chat', |
2171 | say_command => 'chat', |
2101 | audio_enable => 1, |
2172 | audio_enable => 1, |
2102 | bgm_enable => 1, |
2173 | bgm_enable => 1, |
2103 | bgm_volume => 0.25, |
2174 | bgm_volume => 0.25, |
2104 | face_prefetch => 0, |
2175 | face_prefetch => 0, |
2105 | output_sync => 1, |
2176 | output_sync => 1, |
2106 | output_count => 1, |
2177 | output_count => 1, |
2107 | output_rate => "", |
2178 | output_rate => "", |
2108 | pickup => 0, |
2179 | pickup => 0, |
2109 | inv_sort => "mtime", |
2180 | inv_sort => "mtime", |
2110 | default => "profile", # default profile |
2181 | default => "profile", # default profile |
2111 | show_tips => 1, |
2182 | show_tips => 1, |
|
|
2183 | logview_max_par => 1000, |
2112 | ); |
2184 | ); |
2113 | |
2185 | |
2114 | while (my ($k, $v) = each %DEF_CFG) { |
2186 | while (my ($k, $v) = each %DEF_CFG) { |
2115 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
2187 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
2116 | } |
2188 | } |
… | |
… | |
2185 | |
2257 | |
2186 | Event::loop; |
2258 | Event::loop; |
2187 | #CFPlus::SDL_Quit; |
2259 | #CFPlus::SDL_Quit; |
2188 | #CFPlus::_exit 0; |
2260 | #CFPlus::_exit 0; |
2189 | |
2261 | |
|
|
2262 | END { |
2190 | END { CFPlus::SDL_Quit } |
2263 | CFPlus::SDL_Quit; |
|
|
2264 | CFPlus::DB::Server::stop; |
|
|
2265 | } |
2191 | |
2266 | |
2192 | =head1 NAME |
2267 | =head1 NAME |
2193 | |
2268 | |
2194 | cfplus - A Crossfire+ and Crossfire game client |
2269 | cfplus - A Crossfire+ and Crossfire game client |
2195 | |
2270 | |