… | |
… | |
37 | use CFClient; |
37 | use CFClient; |
38 | use CFClient::UI; |
38 | use CFClient::UI; |
39 | use CFClient::MapWidget; |
39 | use CFClient::MapWidget; |
40 | |
40 | |
41 | $Event::DIED = sub { |
41 | $Event::DIED = sub { |
|
|
42 | # TODO: display dialog box or so |
42 | CFClient::error $_[1]; |
43 | CFClient::error $_[1]; |
43 | }; |
44 | }; |
44 | |
45 | |
45 | #$SIG{__WARN__} = sub { Carp::cluck $_[0] };#d# |
46 | #$SIG{__WARN__} = sub { Carp::cluck $_[0] };#d# |
46 | |
47 | |
… | |
… | |
59 | our $NOW; |
60 | our $NOW; |
60 | |
61 | |
61 | our $CFG; |
62 | our $CFG; |
62 | our $CONN; |
63 | our $CONN; |
63 | our $FAST; # fast, low-quality mode, possibly useful for software-rendering |
64 | our $FAST; # fast, low-quality mode, possibly useful for software-rendering |
|
|
65 | |
|
|
66 | our $WANT_REFRESH; |
|
|
67 | our $CAN_REFRESH; |
64 | |
68 | |
65 | our @SDL_MODES; |
69 | our @SDL_MODES; |
66 | our $WIDTH; |
70 | our $WIDTH; |
67 | our $HEIGHT; |
71 | our $HEIGHT; |
68 | our $FULLSCREEN; |
72 | our $FULLSCREEN; |
… | |
… | |
90 | our $SDL_MIXER; |
94 | our $SDL_MIXER; |
91 | our @SOUNDS; # event => file mapping |
95 | our @SOUNDS; # event => file mapping |
92 | our %AUDIO_CHUNKS; # audio files |
96 | our %AUDIO_CHUNKS; # audio files |
93 | |
97 | |
94 | our $ALT_ENTER_MESSAGE; |
98 | our $ALT_ENTER_MESSAGE; |
95 | our $STATUS_LINE; |
99 | our $STATUSBOX; |
96 | our $DEBUG_STATUS; |
100 | our $DEBUG_STATUS; |
97 | |
101 | |
98 | our $INVWIN; |
102 | our $INVWIN; |
99 | our $INV; |
103 | our $INV; |
100 | |
104 | |
101 | sub status { |
105 | sub status { |
102 | $STATUS_LINE->set_text ($_[0]); |
106 | $STATUSBOX->add ($_[0], pri => -10, group => "status", timeout => 20, color => [1, 1, 0, 1]); |
103 | $STATUS_LINE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $STATUS_LINE->{h}); |
107 | $CFClient::UI::ROOT->on_post_alloc (status_line_positioner => sub { |
|
|
108 | my $widget = $STATUSBOX->{parent}; |
|
|
109 | $widget->move (0, $HEIGHT - $widget->{h});#d# to in toplevel |
|
|
110 | }); |
104 | } |
111 | } |
105 | |
112 | |
106 | sub debug { |
113 | sub debug { |
107 | $DEBUG_STATUS->set_text ($_[0]); |
114 | $DEBUG_STATUS->set_text ($_[0]); |
108 | $DEBUG_STATUS->move ($WIDTH - $DEBUG_STATUS->{w}, 0, $DEBUG_STATUS->{w}, $DEBUG_STATUS->{h}); |
115 | my ($w, $h) = $DEBUG_STATUS->size_request; |
|
|
116 | $DEBUG_STATUS->move ($WIDTH - $w, 0); |
109 | } |
117 | } |
110 | |
118 | |
111 | sub start_game { |
119 | sub start_game { |
112 | status "logging in..."; |
120 | status "logging in..."; |
113 | |
121 | |
… | |
… | |
374 | y => $HEIGHT - $gh, x => 0, user_w => $WIDTH, user_h => $gh |
382 | y => $HEIGHT - $gh, x => 0, user_w => $WIDTH, user_h => $gh |
375 | ); |
383 | ); |
376 | $win->add (my $hbox = new CFClient::UI::HBox |
384 | $win->add (my $hbox = new CFClient::UI::HBox |
377 | children => [ |
385 | children => [ |
378 | (new CFClient::UI::HBox expand => 1), |
386 | (new CFClient::UI::HBox expand => 1), |
379 | ($FLOORBOX = new CFClient::UI::VBox), |
387 | (new CFClient::UI::VBox children => [ |
|
|
388 | (new CFClient::UI::Empty expand => 1), |
|
|
389 | (new CFClient::UI::Frame bg => [0, 0, 0, 0.4], child => ($FLOORBOX = new CFClient::UI::VBox)), |
|
|
390 | ]), |
380 | (my $vbox = new CFClient::UI::VBox), |
391 | (my $vbox = new CFClient::UI::VBox), |
381 | ], |
392 | ], |
382 | ); |
393 | ); |
383 | |
394 | |
384 | $vbox->add (new CFClient::UI::HBox |
395 | $vbox->add (new CFClient::UI::HBox |
… | |
… | |
828 | |
839 | |
829 | CFClient::SDL_SetVideoMode $WIDTH, $HEIGHT, $FULLSCREEN |
840 | CFClient::SDL_SetVideoMode $WIDTH, $HEIGHT, $FULLSCREEN |
830 | or die "SDL_SetVideoMode failed!\n"; |
841 | or die "SDL_SetVideoMode failed!\n"; |
831 | |
842 | |
832 | $SDL_ACTIVE = 1; |
843 | $SDL_ACTIVE = 1; |
833 | |
|
|
834 | $LAST_REFRESH = time - 0.01; |
844 | $LAST_REFRESH = time - 0.01; |
835 | |
845 | |
836 | CFClient::gl_init; |
846 | CFClient::gl_init; |
837 | |
847 | |
838 | $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize}; |
848 | $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize}; |
839 | |
849 | |
|
|
850 | $CFClient::UI::ROOT->configure (0, 0, $WIDTH, $HEIGHT);#d# |
|
|
851 | |
840 | ############################################################################# |
852 | ############################################################################# |
841 | |
853 | |
|
|
854 | if ($DEBUG_STATUS) { |
|
|
855 | # reconfigure all widgets |
|
|
856 | $CFClient::UI::ROOT->reconfigure; |
|
|
857 | |
|
|
858 | } else { |
|
|
859 | # create the widgets |
|
|
860 | |
842 | $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100; |
861 | $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100, text => "hulla", x => 100;#d# |
843 | $DEBUG_STATUS->show; |
862 | $DEBUG_STATUS->show; |
844 | |
863 | |
845 | $STATUS_LINE = new CFClient::UI::Label |
864 | $STATUSBOX = new CFClient::UI::Statusbox; |
846 | padding => 0, |
865 | $STATUSBOX->add ("Use <b>Alt-Enter</b> to toggle fullscreen mode", pri => -100, size => 0.8, color => [1, 1, 1, 0.8]); |
847 | y => $HEIGHT - $FONTSIZE * 1.8; |
|
|
848 | $STATUS_LINE->show; |
|
|
849 | |
866 | |
850 | $ALT_ENTER_MESSAGE = new CFClient::UI::Label |
867 | (new CFClient::UI::Frame |
851 | padding => 0, |
868 | bg => [0, 0, 0, 0.4], |
852 | fontsize => 0.8, |
869 | child => $STATUSBOX, |
853 | markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; |
870 | )->show; |
854 | $ALT_ENTER_MESSAGE->show; |
|
|
855 | $ALT_ENTER_MESSAGE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h}); |
|
|
856 | |
871 | |
857 | CFClient::UI::FancyFrame->new ( |
872 | CFClient::UI::FancyFrame->new ( |
858 | border_bg => [1, 1, 1, 192/255], |
873 | border_bg => [1, 1, 1, 192/255], |
859 | bg => [1, 1, 1, 0], |
874 | bg => [1, 1, 1, 0], |
860 | child => ($MAPMAP = new CFClient::MapWidget::MapMap), |
875 | child => ($MAPMAP = new CFClient::MapWidget::MapMap), |
861 | )->show; |
876 | )->show; |
862 | |
877 | |
863 | $MAPWIDGET = new CFClient::MapWidget; |
878 | $MAPWIDGET = new CFClient::MapWidget; |
864 | $MAPWIDGET->connect (activate_console => sub { |
879 | $MAPWIDGET->connect (activate_console => sub { |
865 | my ($mapwidget, $preset) = @_; |
880 | my ($mapwidget, $preset) = @_; |
866 | |
881 | |
867 | if ($CONSOLE) { |
882 | if ($CONSOLE) { |
868 | $CONSOLE->{input}->{auto_activated} = 1; |
883 | $CONSOLE->{input}->{auto_activated} = 1; |
869 | $CONSOLE->{input}->focus_in; |
884 | $CONSOLE->{input}->focus_in; |
870 | |
885 | |
871 | if ($preset && $CONSOLE->{input}->get_text eq '') { |
886 | if ($preset && $CONSOLE->{input}->get_text eq '') { |
872 | $CONSOLE->{input}->set_text ($preset); |
887 | $CONSOLE->{input}->set_text ($preset); |
|
|
888 | } |
873 | } |
889 | } |
874 | } |
890 | }); |
875 | }); |
|
|
876 | $MAPWIDGET->show; |
891 | $MAPWIDGET->show; |
877 | $MAPWIDGET->focus_in; |
892 | $MAPWIDGET->focus_in; |
878 | |
893 | |
879 | $BUTTONBAR = new CFClient::UI::HBox; |
894 | $BUTTONBAR = new CFClient::UI::HBox; |
880 | |
895 | |
881 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Client Setup", other => client_setup); |
896 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Client Setup", other => client_setup); |
882 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Server Setup", other => server_setup); |
897 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Server Setup", other => server_setup); |
883 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => message_window); |
898 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => message_window); |
884 | |
899 | |
885 | 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 |
900 | 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 |
886 | |
901 | |
887 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window); |
902 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window); |
888 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Inventory", other => make_inventory_window); |
903 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Inventory", other => make_inventory_window); |
889 | |
904 | |
890 | $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub { |
905 | $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub { |
891 | CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; |
906 | CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; |
892 | status "Configuration Saved"; |
907 | status "Configuration Saved"; |
893 | }); |
908 | }); |
894 | |
909 | |
895 | $BUTTONBAR->show; |
910 | $BUTTONBAR->show; |
896 | |
911 | |
|
|
912 | # delay till geometry is constant |
|
|
913 | $CFClient::UI::ROOT->on_post_alloc (startup => sub { |
897 | $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup |
914 | $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup |
|
|
915 | }); |
|
|
916 | force_refresh (); |
|
|
917 | } |
898 | } |
918 | } |
899 | |
919 | |
900 | sub video_shutdown { |
920 | sub video_shutdown { |
901 | $CFClient::UI::ROOT->{children} = []; |
|
|
902 | undef $CFClient::UI::GRAB; |
|
|
903 | undef $CFClient::UI::HOVER; |
|
|
904 | undef $SDL_ACTIVE; |
921 | undef $SDL_ACTIVE; |
905 | } |
922 | } |
906 | |
923 | |
907 | my @bgmusic = qw(game1.ogg game2.ogg game3.ogg game5.ogg game6.ogg ross1.ogg ross2.ogg ross3.ogg ross4.ogg ross5.ogg); #d# |
924 | my @bgmusic = qw(game1.ogg game2.ogg game3.ogg game5.ogg game6.ogg ross1.ogg ross2.ogg ross3.ogg ross4.ogg ross5.ogg); #d# |
908 | my $bgmusic;#TODO#hack#d# |
925 | my $bgmusic;#TODO#hack#d# |
… | |
… | |
960 | } |
977 | } |
961 | |
978 | |
962 | my %animate_object; |
979 | my %animate_object; |
963 | my $animate_timer; |
980 | my $animate_timer; |
964 | |
981 | |
965 | my $want_refresh; |
|
|
966 | my $can_refresh; |
|
|
967 | |
|
|
968 | my $fps = 9; |
982 | my $fps = 9; |
969 | |
983 | |
970 | sub force_refresh { |
984 | sub force_refresh { |
971 | $fps = $fps * 0.95 + 1 / ($NOW - $LAST_REFRESH) * 0.05; |
985 | $fps = $fps * 0.95 + 1 / ($NOW - $LAST_REFRESH) * 0.05; |
972 | debug sprintf "%3.2f", $fps; |
986 | debug sprintf "%3.2f", $fps; |
973 | |
987 | |
974 | $want_refresh = 0; |
|
|
975 | $can_refresh = 0; |
|
|
976 | |
|
|
977 | $CFClient::UI::ROOT->draw; |
988 | $CFClient::UI::ROOT->draw; |
978 | |
|
|
979 | CFClient::SDL_GL_SwapBuffers; |
989 | CFClient::SDL_GL_SwapBuffers; |
980 | |
990 | |
|
|
991 | $WANT_REFRESH = 0; |
|
|
992 | $CAN_REFRESH = 0; |
981 | $LAST_REFRESH = $NOW; |
993 | $LAST_REFRESH = $NOW; |
982 | } |
994 | } |
983 | |
995 | |
984 | my $refresh_watcher = Event->timer (after => 0, hard => 1, interval => 1 / $MAX_FPS, cb => sub { |
996 | my $refresh_watcher = Event->timer (after => 0, hard => 1, interval => 1 / $MAX_FPS, cb => sub { |
985 | $NOW = time; |
997 | $NOW = time; |
… | |
… | |
987 | ($SDL_CB{$_->{type}} || sub { warn "unhandled event $_->{type}" })->($_) |
999 | ($SDL_CB{$_->{type}} || sub { warn "unhandled event $_->{type}" })->($_) |
988 | for CFClient::SDL_PollEvent; |
1000 | for CFClient::SDL_PollEvent; |
989 | |
1001 | |
990 | if (%animate_object) { |
1002 | if (%animate_object) { |
991 | $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; |
1003 | $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; |
992 | $want_refresh++; |
1004 | $WANT_REFRESH++; |
993 | } |
1005 | } |
994 | |
1006 | |
995 | if ($want_refresh) { |
1007 | if ($WANT_REFRESH) { |
996 | force_refresh; |
1008 | force_refresh; |
997 | } else { |
1009 | } else { |
998 | $can_refresh = 1; |
1010 | $CAN_REFRESH = 1; |
999 | } |
1011 | } |
1000 | }); |
1012 | }); |
1001 | |
|
|
1002 | sub refresh { |
|
|
1003 | $want_refresh++; |
|
|
1004 | } |
|
|
1005 | |
1013 | |
1006 | sub animation_start { |
1014 | sub animation_start { |
1007 | my ($widget) = @_; |
1015 | my ($widget) = @_; |
1008 | $animate_object{$widget} = $widget; |
1016 | $animate_object{$widget} = $widget; |
1009 | } |
1017 | } |
… | |
… | |
1321 | [0.55, 0.41, 0.13], |
1329 | [0.55, 0.41, 0.13], |
1322 | [0.99, 0.77, 0.26], |
1330 | [0.99, 0.77, 0.26], |
1323 | [0.74, 0.65, 0.41], |
1331 | [0.74, 0.65, 0.41], |
1324 | ); |
1332 | ); |
1325 | |
1333 | |
|
|
1334 | my $time = sprintf "%02d:%02d:%02d", (localtime time)[2,1,0]; |
|
|
1335 | |
|
|
1336 | $text =~ s/&/&/g; $text =~ s/</</g; |
|
|
1337 | $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g; |
|
|
1338 | $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g; |
|
|
1339 | |
1326 | $LOGVIEW->add_paragraph ($color[$color], $text); |
1340 | $LOGVIEW->add_paragraph ($color[$color], |
|
|
1341 | join "\n", map "$time $_", split /\n/, $text); |
|
|
1342 | |
|
|
1343 | $STATUSBOX->add ($text, |
|
|
1344 | group => $text, |
|
|
1345 | color => $color[$color], |
|
|
1346 | timeout => 60, |
|
|
1347 | tooltip_font => $::FONT_FIXED, |
|
|
1348 | ); |
|
|
1349 | } |
|
|
1350 | |
|
|
1351 | sub conn::drawextinfo { |
|
|
1352 | my ($self, $color, $type, $subtype, $message) = @_; |
|
|
1353 | |
|
|
1354 | $self->drawinfo ($color, $message); |
1327 | } |
1355 | } |
1328 | |
1356 | |
1329 | sub conn::spell_add { |
1357 | sub conn::spell_add { |
1330 | my ($self, $spell) = @_; |
1358 | my ($self, $spell) = @_; |
1331 | |
1359 | |
… | |
… | |
1362 | return unless $CONN; |
1390 | return unless $CONN; |
1363 | |
1391 | |
1364 | $FLOORBOX->clear; |
1392 | $FLOORBOX->clear; |
1365 | $FLOORBOX->add (new CFClient::UI::Empty expand => 1); |
1393 | $FLOORBOX->add (new CFClient::UI::Empty expand => 1); |
1366 | |
1394 | |
1367 | # we basically have to use the same sorting as everybody else |
1395 | my $count = 4; |
1368 | for my $item (@{ $CONN->{container}{0} }) { |
1396 | for (@{ $CONN->{container}{0} }) { |
|
|
1397 | if (--$count) { |
1369 | $FLOORBOX->add (new CFClient::UI::InventoryItem item => $item); |
1398 | $FLOORBOX->add (new CFClient::UI::InventoryItem item => $_); |
|
|
1399 | } else { |
|
|
1400 | $FLOORBOX->add (new CFClient::UI::Label text => "More..."); |
|
|
1401 | last; |
|
|
1402 | } |
1370 | } |
1403 | } |
1371 | }); |
1404 | }); |
1372 | refresh; |
1405 | |
|
|
1406 | $WANT_REFRESH++; |
1373 | } |
1407 | } |
1374 | |
1408 | |
1375 | sub conn::container_add { |
1409 | sub conn::container_add { |
1376 | my ($self, $id, $items) = @_; |
1410 | my ($self, $tag, $items) = @_; |
1377 | |
1411 | |
1378 | update_floorbox if $id == 0; |
1412 | update_floorbox if $tag == 0; |
1379 | if ($self->{player}{tag} == $id) { |
1413 | |
1380 | $INV->set_items ($self->{container}{$self->{player}{tag}}); |
1414 | $INV->set_items ($self->{container}{$self->{player}{tag}}) |
1381 | } |
1415 | if $tag == $self->{player}{tag}; |
|
|
1416 | |
1382 | # $self-<{player}{tag} => player inv |
1417 | # $self-<{player}{tag} => player inv |
1383 | #use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}}; |
1418 | #use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}}; |
1384 | } |
1419 | } |
1385 | |
1420 | |
1386 | sub conn::container_clear { |
1421 | sub conn::container_clear { |
1387 | my ($self, $id) = @_; |
1422 | my ($self, $tag) = @_; |
1388 | |
1423 | |
1389 | update_floorbox if $id == 0; |
1424 | update_floorbox if $tag == 0; |
1390 | if ($self->{player}{tag} == $id) { |
1425 | |
1391 | $INV->set_items ($self->{container}{$id}); |
1426 | $INV->set_items ($self->{container}{$tag}) |
1392 | } |
1427 | if $tag == $self->{player}{tag}; |
1393 | |
1428 | |
1394 | # use PApp::Util; warn PApp::Util::dumpval $self->{container}{0}; |
1429 | # use PApp::Util; warn PApp::Util::dumpval $self->{container}{0}; |
1395 | } |
1430 | } |
1396 | |
1431 | |
1397 | sub conn::item_delete { |
1432 | sub conn::item_delete { |
1398 | my ($self, @items) = @_; |
1433 | my ($self, @items) = @_; |
1399 | |
1434 | |
1400 | for (@items) { |
1435 | for (@items) { |
1401 | update_floorbox if $_->{container} == 0; |
1436 | update_floorbox if $_->{container} == 0; |
1402 | if ($self->{player}{tag} == $_->{container}) { |
1437 | |
1403 | $INV->set_items ($self->{container}{$_->{container}}); |
1438 | $INV->set_items ($self->{container}{$_->{container}}) |
1404 | } |
1439 | if $_->{container} == $self->{player}{tag}; |
1405 | } |
1440 | } |
1406 | } |
1441 | } |
1407 | |
1442 | |
1408 | sub conn::item_update { |
1443 | sub conn::item_update { |
1409 | my ($self, $item) = @_; |
1444 | my ($self, $item) = @_; |
1410 | |
1445 | |
1411 | update_floorbox if $item->{container} == 0; |
1446 | update_floorbox if $item->{container} == 0; |
1412 | if ($self->{player}{tag} == $item->{container}) { |
1447 | |
1413 | $INV->set_items ($self->{container}{$item->{container}}); |
1448 | $INV->set_items ($self->{container}{$item->{container}}) |
1414 | } |
1449 | if $item->{container} == $self->{player}{tag}; |
1415 | } |
1450 | } |
1416 | |
1451 | |
1417 | %SDL_CB = ( |
1452 | %SDL_CB = ( |
1418 | CFClient::SDL_QUIT => sub { |
1453 | CFClient::SDL_QUIT => sub { |
1419 | Event::unloop -1; |
1454 | Event::unloop -1; |
1420 | }, |
1455 | }, |
1421 | CFClient::SDL_VIDEORESIZE => sub { |
1456 | CFClient::SDL_VIDEORESIZE => sub { |
1422 | }, |
1457 | }, |
1423 | CFClient::SDL_VIDEOEXPOSE => \&refresh, |
1458 | CFClient::SDL_VIDEOEXPOSE => sub { |
|
|
1459 | $WANT_REFRESH++; |
|
|
1460 | }, |
1424 | CFClient::SDL_ACTIVEEVENT => sub { |
1461 | CFClient::SDL_ACTIVEEVENT => sub { |
1425 | # printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d# |
1462 | # printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d# |
1426 | }, |
1463 | }, |
1427 | CFClient::SDL_KEYDOWN => sub { |
1464 | CFClient::SDL_KEYDOWN => sub { |
1428 | if ($_[0]{mod} & CFClient::KMOD_ALT && $_[0]{sym} == 13) { |
1465 | if ($_[0]{mod} & CFClient::KMOD_ALT && $_[0]{sym} == 13) { |
… | |
… | |
1449 | |
1486 | |
1450 | ############################################################################# |
1487 | ############################################################################# |
1451 | |
1488 | |
1452 | $SIG{INT} = $SIG{TERM} = sub { exit }; |
1489 | $SIG{INT} = $SIG{TERM} = sub { exit }; |
1453 | |
1490 | |
1454 | CFClient::read_cfg "$Crossfire::VARDIR/pclientrc"; |
|
|
1455 | |
|
|
1456 | $TILECACHE = CFClient::db_table "tilecache"; |
|
|
1457 | $FACEMAP = CFClient::db_table "facemap"; |
|
|
1458 | |
|
|
1459 | my %DEF_CFG = ( |
|
|
1460 | sdl_mode => 0, |
|
|
1461 | width => 640, |
|
|
1462 | height => 480, |
|
|
1463 | fullscreen => 0, |
|
|
1464 | fast => 0, |
|
|
1465 | map_scale => 0.5, |
|
|
1466 | fow_enable => 1, |
|
|
1467 | fow_intensity => 0.45, |
|
|
1468 | fow_smooth => 0, |
|
|
1469 | gui_fontsize => 1, |
|
|
1470 | log_fontsize => 1, |
|
|
1471 | gauge_fontsize => 1, |
|
|
1472 | gauge_size => 0.35, |
|
|
1473 | stat_fontsize => 1, |
|
|
1474 | mapsize => 100, |
|
|
1475 | host => "crossfire.schmorp.de", |
|
|
1476 | say_command => 'say', |
|
|
1477 | audio_enable => 1, |
|
|
1478 | bgm_enable => 1, |
|
|
1479 | bgm_volume => 0.25, |
|
|
1480 | ); |
|
|
1481 | |
|
|
1482 | while (my ($k, $v) = each %DEF_CFG) { |
|
|
1483 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
|
|
1484 | } |
|
|
1485 | |
|
|
1486 | sdl_init; |
|
|
1487 | |
|
|
1488 | @SDL_MODES = reverse |
|
|
1489 | grep $_->[0] >= 640 && $_->[1] >= 480, |
|
|
1490 | CFClient::SDL_ListModes; |
|
|
1491 | |
|
|
1492 | @SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; |
|
|
1493 | |
|
|
1494 | $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES; |
|
|
1495 | |
|
|
1496 | { |
1491 | { |
|
|
1492 | local $SIG{__DIE__} = sub { CFClient::fatal $_[0] }; |
|
|
1493 | |
|
|
1494 | CFClient::read_cfg "$Crossfire::VARDIR/pclientrc"; |
|
|
1495 | |
|
|
1496 | $TILECACHE = CFClient::db_table "tilecache"; |
|
|
1497 | $FACEMAP = CFClient::db_table "facemap"; |
|
|
1498 | |
|
|
1499 | my %DEF_CFG = ( |
|
|
1500 | sdl_mode => 0, |
|
|
1501 | width => 640, |
|
|
1502 | height => 480, |
|
|
1503 | fullscreen => 0, |
|
|
1504 | fast => 0, |
|
|
1505 | map_scale => 0.5, |
|
|
1506 | fow_enable => 1, |
|
|
1507 | fow_intensity => 0.45, |
|
|
1508 | fow_smooth => 0, |
|
|
1509 | gui_fontsize => 1, |
|
|
1510 | log_fontsize => 1, |
|
|
1511 | gauge_fontsize=> 1, |
|
|
1512 | gauge_size => 0.35, |
|
|
1513 | stat_fontsize => 1, |
|
|
1514 | mapsize => 100, |
|
|
1515 | host => "crossfire.schmorp.de", |
|
|
1516 | say_command => 'say', |
|
|
1517 | audio_enable => 1, |
|
|
1518 | bgm_enable => 1, |
|
|
1519 | bgm_volume => 0.25, |
|
|
1520 | ); |
|
|
1521 | |
|
|
1522 | while (my ($k, $v) = each %DEF_CFG) { |
|
|
1523 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
|
|
1524 | } |
|
|
1525 | |
|
|
1526 | sdl_init; |
|
|
1527 | |
|
|
1528 | @SDL_MODES = reverse |
|
|
1529 | grep $_->[0] >= 640 && $_->[1] >= 480, |
|
|
1530 | CFClient::SDL_ListModes; |
|
|
1531 | |
|
|
1532 | @SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; |
|
|
1533 | |
|
|
1534 | $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES; |
|
|
1535 | |
|
|
1536 | { |
1497 | my @fonts = map CFClient::find_rcfile "fonts/$_", qw( |
1537 | my @fonts = map CFClient::find_rcfile "fonts/$_", qw( |
1498 | DejaVuSans.ttf |
1538 | DejaVuSans.ttf |
1499 | DejaVuSansMono.ttf |
1539 | DejaVuSansMono.ttf |
1500 | DejaVuSans-Bold.ttf |
1540 | DejaVuSans-Bold.ttf |
1501 | DejaVuSansMono-Bold.ttf |
1541 | DejaVuSansMono-Bold.ttf |
1502 | DejaVuSans-Oblique.ttf |
1542 | DejaVuSans-Oblique.ttf |
1503 | DejaVuSansMono-Oblique.ttf |
1543 | DejaVuSansMono-Oblique.ttf |
1504 | DejaVuSans-BoldOblique.ttf |
1544 | DejaVuSans-BoldOblique.ttf |
1505 | DejaVuSansMono-BoldOblique.ttf |
1545 | DejaVuSansMono-BoldOblique.ttf |
1506 | ); |
1546 | ); |
1507 | |
1547 | |
1508 | CFClient::add_font $_ for @fonts; |
1548 | CFClient::add_font $_ for @fonts; |
1509 | |
1549 | |
1510 | $FONT_PROP = new_from_file CFClient::Font $fonts[0]; |
1550 | $FONT_PROP = new_from_file CFClient::Font $fonts[0]; |
1511 | $FONT_FIXED = new_from_file CFClient::Font $fonts[1]; |
1551 | $FONT_FIXED = new_from_file CFClient::Font $fonts[1]; |
1512 | |
1552 | |
1513 | $FONT_PROP->make_default; |
1553 | $FONT_PROP->make_default; |
1514 | } |
1554 | } |
1515 | |
1555 | |
1516 | video_init; |
1556 | video_init; |
1517 | audio_init; |
1557 | audio_init; |
|
|
1558 | } |
1518 | |
1559 | |
1519 | Event::loop; |
1560 | Event::loop; |
1520 | |
1561 | |
1521 | END { CFClient::SDL_Quit } |
1562 | END { CFClient::SDL_Quit } |
1522 | |
1563 | |