ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/bin/pclient
(Generate patch)

Comparing deliantra/Deliantra-Client/bin/pclient (file contents):
Revision 1.198 by root, Fri May 5 19:10:16 2006 UTC vs.
Revision 1.206 by root, Tue May 9 22:27:55 2006 UTC

59our $NOW; 59our $NOW;
60 60
61our $CFG; 61our $CFG;
62our $CONN; 62our $CONN;
63our $FAST; # fast, low-quality mode, possibly useful for software-rendering 63our $FAST; # fast, low-quality mode, possibly useful for software-rendering
64
65our $WANT_REFRESH;
66our $CAN_REFRESH;
64 67
65our @SDL_MODES; 68our @SDL_MODES;
66our $WIDTH; 69our $WIDTH;
67our $HEIGHT; 70our $HEIGHT;
68our $FULLSCREEN; 71our $FULLSCREEN;
76our $MAPWIDGET; 79our $MAPWIDGET;
77our $BUTTONBAR; 80our $BUTTONBAR;
78our $LOGVIEW; 81our $LOGVIEW;
79our $CONSOLE; 82our $CONSOLE;
80our $METASERVER; 83our $METASERVER;
84our $LOGIN_BUTTON;
81 85
82our $FLOORBOX; 86our $FLOORBOX;
83our $GAUGES; 87our $GAUGES;
84our $STATWIDS; 88our $STATWIDS;
85 89
102 $STATUS_LINE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $STATUS_LINE->{h}); 106 $STATUS_LINE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $STATUS_LINE->{h});
103} 107}
104 108
105sub debug { 109sub debug {
106 $DEBUG_STATUS->set_text ($_[0]); 110 $DEBUG_STATUS->set_text ($_[0]);
107 $DEBUG_STATUS->move ($WIDTH - $DEBUG_STATUS->{w}, 0, $DEBUG_STATUS->{w}, $DEBUG_STATUS->{h}); 111 my ($w, $h) = $DEBUG_STATUS->size_request;
112 $DEBUG_STATUS->move ($WIDTH - $w, 0);
108} 113}
109 114
110sub start_game { 115sub start_game {
111 status "logging in..."; 116 status "logging in...";
112 117
113 my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; 118 my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32;
114 119
115 $MAPCACHE = CFClient::db_table "mapcache_$CFG->{host}"; 120 $MAPCACHE = CFClient::db_table "mapcache_$CFG->{host}";
116
117 $MAP = new CFClient::Map $mapsize, $mapsize; 121 $MAP = new CFClient::Map $mapsize, $mapsize;
118 122
119 my ($host, $port) = split /:/, $CFG->{host}; 123 my ($host, $port) = split /:/, $CFG->{host};
120 124
121 $CONN = eval { 125 $CONN = eval {
128 maph => $mapsize, 132 maph => $mapsize,
129 ; 133 ;
130 }; 134 };
131 135
132 if ($CONN) { 136 if ($CONN) {
137 $LOGIN_BUTTON->set_text ("Logout");
138
133 status "login successful"; 139 status "login successful";
134 140
135 CFClient::lowdelay fileno $CONN->{fh}; 141 CFClient::lowdelay fileno $CONN->{fh};
136 } else { 142 } else {
137 status "unable to connect"; 143 status "unable to connect";
144 stop_game();
138 } 145 }
139} 146}
140 147
141sub stop_game { 148sub stop_game {
149 return unless $CONN;
150
151 status "connection closed";
152 $LOGIN_BUTTON->set_text ("Login");
153 $CONN->destroy;
154 $CONN = 0; # false, does not autovivify
155
156 undef $MAPCACHE;
142 undef $CONN; 157 undef $MAP;
143} 158}
144 159
145sub client_setup { 160sub client_setup {
146 my $dialog = new CFClient::UI::FancyFrame 161 my $dialog = new CFClient::UI::FancyFrame
147 title => "Client Setup", 162 title => "Client Setup",
571 586
572} 587}
573 588
574sub metaserver_dialog { 589sub metaserver_dialog {
575 my $dialog = new CFClient::UI::FancyFrame 590 my $dialog = new CFClient::UI::FancyFrame
576 title => "Metaserver", 591 title => "Server List",
577 child => (my $vbox = new CFClient::UI::VBox); 592 child => (my $vbox = new CFClient::UI::VBox);
578 593
579 $vbox->add ($dialog->{table} = new CFClient::UI::Table); 594 $vbox->add ($dialog->{table} = new CFClient::UI::Table);
580 595
581 $dialog 596 $dialog
683 698
684 $METASERVER = metaserver_dialog; 699 $METASERVER = metaserver_dialog;
685 700
686 $vbox->add (new CFClient::UI::Flopper 701 $vbox->add (new CFClient::UI::Flopper
687 expand => 1, 702 expand => 1,
688 text => "Metaserver", 703 text => "Server List",
689 other => $METASERVER, 704 other => $METASERVER,
690 tooltip => "Show a list of avaible crossfire servers", 705 tooltip => "Show a list of available crossfire servers",
691 connect_open => sub { 706 connect_open => sub {
692 update_metaserver $HOST; 707 update_metaserver $HOST;
693 } 708 }
694 ); 709 );
695 } 710 }
726 741
727 $CFG->{mapsize} = $self->{range}[0] = $value = int $value; 742 $CFG->{mapsize} = $self->{range}[0] = $value = int $value;
728 }, 743 },
729 ); 744 );
730 745
731 $table->add (1, 8, new CFClient::UI::Button expand => 1, align => 0, text => "Login", connect_activate => sub { 746 $table->add (1, 8, $LOGIN_BUTTON = new CFClient::UI::Button
747 expand => 1,
748 align => 0,
749 text => "Login",
750 connect_activate => sub {
751 $CONN ? stop_game
732 start_game; 752 : start_game;
753 },
733 }); 754 );
734 755
735 $dialog 756 $dialog
736} 757}
737 758
738sub message_window { 759sub message_window {
811 832
812 CFClient::SDL_SetVideoMode $WIDTH, $HEIGHT, $FULLSCREEN 833 CFClient::SDL_SetVideoMode $WIDTH, $HEIGHT, $FULLSCREEN
813 or die "SDL_SetVideoMode failed!\n"; 834 or die "SDL_SetVideoMode failed!\n";
814 835
815 $SDL_ACTIVE = 1; 836 $SDL_ACTIVE = 1;
816
817 $LAST_REFRESH = time - 0.01; 837 $LAST_REFRESH = time - 0.01;
818 838
819 CFClient::gl_init; 839 CFClient::gl_init;
820 840
821 $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize}; 841 $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize};
822 842
843 $CFClient::UI::ROOT->configure (0, 0, $WIDTH, $HEIGHT);#d#
844
823 ############################################################################# 845 #############################################################################
824 846
847 if ($DEBUG_STATUS) {
848 # reconfigure all widgets
849 $CFClient::UI::ROOT->reconfigure;
850
851 } else {
852 # create the widgets
853
825 $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100; 854 $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100, text => "hulla", x => 100;#d#
826 $DEBUG_STATUS->show; 855 $DEBUG_STATUS->show;
827 856
828 $STATUS_LINE = new CFClient::UI::Label 857 $STATUS_LINE = new CFClient::UI::Label
829 padding => 0, 858 padding => 0,
830 y => $HEIGHT - $FONTSIZE * 1.8; 859 y => $HEIGHT - $FONTSIZE * 1.8;
831 $STATUS_LINE->show; 860 $STATUS_LINE->show;
832 861
833 $ALT_ENTER_MESSAGE = new CFClient::UI::Label 862 $ALT_ENTER_MESSAGE = new CFClient::UI::Label
834 padding => 0, 863 padding => 0,
835 fontsize => 0.8, 864 fontsize => 0.8,
836 markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; 865 markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode";
837 $ALT_ENTER_MESSAGE->show; 866 $ALT_ENTER_MESSAGE->show;
838 $ALT_ENTER_MESSAGE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h}); 867 $ALT_ENTER_MESSAGE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h});
839 868
840 CFClient::UI::FancyFrame->new ( 869 CFClient::UI::FancyFrame->new (
841 border_bg => [1, 1, 1, 192/255], 870 border_bg => [1, 1, 1, 192/255],
842 bg => [1, 1, 1, 0], 871 bg => [1, 1, 1, 0],
843 child => ($MAPMAP = new CFClient::MapWidget::MapMap), 872 child => ($MAPMAP = new CFClient::MapWidget::MapMap),
844 )->show; 873 )->show;
845 874
846 $MAPWIDGET = new CFClient::MapWidget; 875 $MAPWIDGET = new CFClient::MapWidget;
847 $MAPWIDGET->connect (activate_console => sub { 876 $MAPWIDGET->connect (activate_console => sub {
848 my ($mapwidget, $preset) = @_; 877 my ($mapwidget, $preset) = @_;
849 878
850 if ($CONSOLE) { 879 if ($CONSOLE) {
851 $CONSOLE->{input}->{auto_activated} = 1; 880 $CONSOLE->{input}->{auto_activated} = 1;
852 $CONSOLE->{input}->focus_in; 881 $CONSOLE->{input}->focus_in;
853 882
854 if ($preset && $CONSOLE->{input}->get_text eq '') { 883 if ($preset && $CONSOLE->{input}->get_text eq '') {
855 $CONSOLE->{input}->set_text ($preset); 884 $CONSOLE->{input}->set_text ($preset);
885 }
856 } 886 }
857 } 887 });
858 });
859 $MAPWIDGET->show; 888 $MAPWIDGET->show;
860 $MAPWIDGET->focus_in; 889 $MAPWIDGET->focus_in;
861 890
862 $BUTTONBAR = new CFClient::UI::HBox; 891 $BUTTONBAR = new CFClient::UI::HBox;
863 892
864 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Client Setup", other => client_setup); 893 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Client Setup", other => client_setup);
865 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Server Setup", other => server_setup); 894 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Server Setup", other => server_setup);
866 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => message_window); 895 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => message_window);
867 896
868 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 897 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
869 898
870 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window); 899 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window);
871 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Inventory", other => make_inventory_window); 900 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Inventory", other => make_inventory_window);
872 901
873 $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub { 902 $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub {
874 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; 903 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc";
875 status "Configuration Saved"; 904 status "Configuration Saved";
876 }); 905 });
877 906
878 $BUTTONBAR->show; 907 $BUTTONBAR->show;
879 908
909 # delay till geometry is constant
910 $CFClient::UI::ROOT->on_refresh (startup => sub {
880 $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup 911 $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup
912 });
913 force_refresh ();
914 }
881} 915}
882 916
883sub video_shutdown { 917sub video_shutdown {
884 $CFClient::UI::ROOT->{children} = [];
885 undef $CFClient::UI::GRAB;
886 undef $CFClient::UI::HOVER;
887 undef $SDL_ACTIVE; 918 undef $SDL_ACTIVE;
888} 919}
889 920
890my @bgmusic = qw(game1.ogg game2.ogg game3.ogg game5.ogg game6.ogg ross1.ogg ross2.ogg ross3.ogg ross4.ogg ross5.ogg); #d# 921my @bgmusic = qw(game1.ogg game2.ogg game3.ogg game5.ogg game6.ogg ross1.ogg ross2.ogg ross3.ogg ross4.ogg ross5.ogg); #d#
891my $bgmusic;#TODO#hack#d# 922my $bgmusic;#TODO#hack#d#
943} 974}
944 975
945my %animate_object; 976my %animate_object;
946my $animate_timer; 977my $animate_timer;
947 978
948my $want_refresh;
949my $can_refresh;
950
951my $fps = 9; 979my $fps = 9;
952 980
953sub force_refresh { 981sub force_refresh {
954 $fps = $fps * 0.95 + 1 / ($NOW - $LAST_REFRESH) * 0.05; 982 $fps = $fps * 0.95 + 1 / ($NOW - $LAST_REFRESH) * 0.05;
955 debug sprintf "%3.2f", $fps; 983 debug sprintf "%3.2f", $fps;
956 984
957 $want_refresh = 0;
958 $can_refresh = 0;
959
960 $CFClient::UI::ROOT->draw; 985 $CFClient::UI::ROOT->draw;
961
962 CFClient::SDL_GL_SwapBuffers; 986 CFClient::SDL_GL_SwapBuffers;
963 987
988 $WANT_REFRESH = 0;
989 $CAN_REFRESH = 0;
964 $LAST_REFRESH = $NOW; 990 $LAST_REFRESH = $NOW;
965} 991}
966 992
967my $refresh_watcher = Event->timer (after => 0, hard => 1, interval => 1 / $MAX_FPS, cb => sub { 993my $refresh_watcher = Event->timer (after => 0, hard => 1, interval => 1 / $MAX_FPS, cb => sub {
968 $NOW = time; 994 $NOW = time;
970 ($SDL_CB{$_->{type}} || sub { warn "unhandled event $_->{type}" })->($_) 996 ($SDL_CB{$_->{type}} || sub { warn "unhandled event $_->{type}" })->($_)
971 for CFClient::SDL_PollEvent; 997 for CFClient::SDL_PollEvent;
972 998
973 if (%animate_object) { 999 if (%animate_object) {
974 $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; 1000 $_->animate ($LAST_REFRESH - $NOW) for values %animate_object;
975 $want_refresh++; 1001 $WANT_REFRESH++;
976 } 1002 }
977 1003
978 if ($want_refresh) { 1004 if ($WANT_REFRESH) {
979 force_refresh; 1005 force_refresh;
980 } else { 1006 } else {
981 $can_refresh = 1; 1007 $CAN_REFRESH = 1;
982 } 1008 }
983}); 1009});
984
985sub refresh {
986 $want_refresh++;
987}
988 1010
989sub animation_start { 1011sub animation_start {
990 my ($widget) = @_; 1012 my ($widget) = @_;
991 $animate_object{$widget} = $widget; 1013 $animate_object{$widget} = $widget;
992} 1014}
1327 1349
1328 for my $skill (values %{$self->{skill_info}}) { 1350 for my $skill (values %{$self->{skill_info}}) {
1329 $MAPWIDGET->add_command ("ready_skill $skill", "Ready the skill '$skill'"); 1351 $MAPWIDGET->add_command ("ready_skill $skill", "Ready the skill '$skill'");
1330 $MAPWIDGET->add_command ("use_skill $skill", "Immediately use the skill '$skill'"); 1352 $MAPWIDGET->add_command ("use_skill $skill", "Immediately use the skill '$skill'");
1331 } 1353 }
1354
1355 $MAPWIDGET->add_command ("pet\\_mode defend", "Tell pets to stay close to you and defend you");
1356 $MAPWIDGET->add_command ("pet\\_mode arena", "Same as petmode attack, but also attack other players");
1357 $MAPWIDGET->add_command ("pet\\_mode sad", "Search &amp; Destroy - tell pets to roam about and attack enemies");
1358 $MAPWIDGET->add_command ("kill\\_pets", "kill your pets");
1359}
1360
1361sub conn::eof {
1362 stop_game;
1332} 1363}
1333 1364
1334sub update_floorbox { 1365sub update_floorbox {
1335 $CFClient::UI::ROOT->on_refresh ($FLOORBOX => sub { 1366 $CFClient::UI::ROOT->on_refresh ($FLOORBOX => sub {
1367 return unless $CONN;
1368
1336 $FLOORBOX->clear; 1369 $FLOORBOX->clear;
1337 $FLOORBOX->add (new CFClient::UI::Empty expand => 1); 1370 $FLOORBOX->add (new CFClient::UI::Empty expand => 1);
1338 1371
1339 # we basically have to use the same sorting as everybody else 1372 # we basically have to use the same sorting as everybody else
1340 for my $item (@{ $CONN->{container}{0} }) { 1373 $FLOORBOX->add (
1341 $FLOORBOX->add (new CFClient::UI::InventoryItem item => $item); 1374 map +(new CFClient::UI::InventoryItem item => $_),
1375 @{ $CONN->{container}{0} }
1342 } 1376 );
1343 }); 1377 });
1344 refresh; 1378
1379 $WANT_REFRESH++;
1345} 1380}
1346 1381
1347sub conn::container_add { 1382sub conn::container_add {
1348 my ($self, $id, $items) = @_; 1383 my ($self, $tag, $items) = @_;
1349 1384
1350 update_floorbox if $id == 0; 1385 update_floorbox if $tag == 0;
1351 if ($self->{player}{tag} == $id) { 1386
1352 $INV->set_items ($self->{container}{$self->{player}{tag}}); 1387 $INV->set_items ($self->{container}{$self->{player}{tag}})
1353 } 1388 if $tag == $self->{player}{tag};
1389
1354 # $self-<{player}{tag} => player inv 1390 # $self-<{player}{tag} => player inv
1355 #use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}}; 1391 #use PApp::Util; warn PApp::Util::dumpval $self->{container}{$self->{player}{tag}};
1356} 1392}
1357 1393
1358sub conn::container_clear { 1394sub conn::container_clear {
1359 my ($self, $id) = @_; 1395 my ($self, $tag) = @_;
1360 1396
1361 update_floorbox if $id == 0; 1397 update_floorbox if $tag == 0;
1362 if ($self->{player}{tag} == $id) { 1398
1363 $INV->set_items ($self->{container}{$id}); 1399 $INV->set_items ($self->{container}{$tag})
1364 } 1400 if $tag == $self->{player}{tag};
1365 1401
1366# use PApp::Util; warn PApp::Util::dumpval $self->{container}{0}; 1402# use PApp::Util; warn PApp::Util::dumpval $self->{container}{0};
1367} 1403}
1368 1404
1369sub conn::item_delete { 1405sub conn::item_delete {
1370 my ($self, @items) = @_; 1406 my ($self, @items) = @_;
1371 1407
1372 for (@items) { 1408 for (@items) {
1373 update_floorbox if $_->{container} == 0; 1409 update_floorbox if $_->{container} == 0;
1374 if ($self->{player}{tag} == $_->{container}) { 1410
1375 $INV->set_items ($self->{container}{$_->{container}}); 1411 $INV->set_items ($self->{container}{$_->{container}})
1376 } 1412 if $_->{container} == $self->{player}{tag};
1377 } 1413 }
1378} 1414}
1379 1415
1380sub conn::item_update { 1416sub conn::item_update {
1381 my ($self, $item) = @_; 1417 my ($self, $item) = @_;
1382 1418
1383 update_floorbox if $item->{container} == 0; 1419 update_floorbox if $item->{container} == 0;
1384 if ($self->{player}{tag} == $item->{container}) { 1420
1385 $INV->set_items ($self->{container}{$item->{container}}); 1421 $INV->set_items ($self->{container}{$item->{container}})
1386 } 1422 if $item->{container} == $self->{player}{tag};
1387} 1423}
1388 1424
1389%SDL_CB = ( 1425%SDL_CB = (
1390 CFClient::SDL_QUIT => sub { 1426 CFClient::SDL_QUIT => sub {
1391 Event::unloop -1; 1427 Event::unloop -1;
1392 }, 1428 },
1393 CFClient::SDL_VIDEORESIZE => sub { 1429 CFClient::SDL_VIDEORESIZE => sub {
1394 }, 1430 },
1395 CFClient::SDL_VIDEOEXPOSE => \&refresh, 1431 CFClient::SDL_VIDEOEXPOSE => sub {
1432 $WANT_REFRESH++;
1433 },
1396 CFClient::SDL_ACTIVEEVENT => sub { 1434 CFClient::SDL_ACTIVEEVENT => sub {
1397# printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d# 1435# printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d#
1398 }, 1436 },
1399 CFClient::SDL_KEYDOWN => sub { 1437 CFClient::SDL_KEYDOWN => sub {
1400 if ($_[0]{mod} & CFClient::KMOD_ALT && $_[0]{sym} == 13) { 1438 if ($_[0]{mod} & CFClient::KMOD_ALT && $_[0]{sym} == 13) {
1421 1459
1422############################################################################# 1460#############################################################################
1423 1461
1424$SIG{INT} = $SIG{TERM} = sub { exit }; 1462$SIG{INT} = $SIG{TERM} = sub { exit };
1425 1463
1426CFClient::read_cfg "$Crossfire::VARDIR/pclientrc";
1427
1428$TILECACHE = CFClient::db_table "tilecache";
1429$FACEMAP = CFClient::db_table "facemap";
1430
1431my %DEF_CFG = (
1432 sdl_mode => 0,
1433 width => 640,
1434 height => 480,
1435 fullscreen => 0,
1436 fast => 0,
1437 map_scale => 0.5,
1438 fow_enable => 1,
1439 fow_intensity => 0.45,
1440 fow_smooth => 0,
1441 gui_fontsize => 1,
1442 log_fontsize => 1,
1443 gauge_fontsize => 1,
1444 gauge_size => 0.35,
1445 stat_fontsize => 1,
1446 mapsize => 100,
1447 host => "crossfire.schmorp.de",
1448 say_command => 'say',
1449 audio_enable => 1,
1450 bgm_enable => 1,
1451 bgm_volume => 0.25,
1452);
1453
1454while (my ($k, $v) = each %DEF_CFG) {
1455 $CFG->{$k} = $v unless exists $CFG->{$k};
1456}
1457
1458sdl_init;
1459
1460@SDL_MODES = reverse
1461 grep $_->[0] >= 640 && $_->[1] >= 480,
1462 CFClient::SDL_ListModes;
1463
1464@SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)";
1465
1466$CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES;
1467
1468{ 1464{
1465 local $SIG{__DIE__} = sub { CFClient::fatal $_[0] };
1466
1467 CFClient::read_cfg "$Crossfire::VARDIR/pclientrc";
1468
1469 $TILECACHE = CFClient::db_table "tilecache";
1470 $FACEMAP = CFClient::db_table "facemap";
1471
1472 my %DEF_CFG = (
1473 sdl_mode => 0,
1474 width => 640,
1475 height => 480,
1476 fullscreen => 0,
1477 fast => 0,
1478 map_scale => 0.5,
1479 fow_enable => 1,
1480 fow_intensity => 0.45,
1481 fow_smooth => 0,
1482 gui_fontsize => 1,
1483 log_fontsize => 1,
1484 gauge_fontsize=> 1,
1485 gauge_size => 0.35,
1486 stat_fontsize => 1,
1487 mapsize => 100,
1488 host => "crossfire.schmorp.de",
1489 say_command => 'say',
1490 audio_enable => 1,
1491 bgm_enable => 1,
1492 bgm_volume => 0.25,
1493 );
1494
1495 while (my ($k, $v) = each %DEF_CFG) {
1496 $CFG->{$k} = $v unless exists $CFG->{$k};
1497 }
1498
1499 sdl_init;
1500
1501 @SDL_MODES = reverse
1502 grep $_->[0] >= 640 && $_->[1] >= 480,
1503 CFClient::SDL_ListModes;
1504
1505 @SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)";
1506
1507 $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES;
1508
1509 {
1469 my @fonts = map CFClient::find_rcfile "fonts/$_", qw( 1510 my @fonts = map CFClient::find_rcfile "fonts/$_", qw(
1470 DejaVuSans.ttf 1511 DejaVuSans.ttf
1471 DejaVuSansMono.ttf 1512 DejaVuSansMono.ttf
1472 DejaVuSans-Bold.ttf 1513 DejaVuSans-Bold.ttf
1473 DejaVuSansMono-Bold.ttf 1514 DejaVuSansMono-Bold.ttf
1474 DejaVuSans-Oblique.ttf 1515 DejaVuSans-Oblique.ttf
1475 DejaVuSansMono-Oblique.ttf 1516 DejaVuSansMono-Oblique.ttf
1476 DejaVuSans-BoldOblique.ttf 1517 DejaVuSans-BoldOblique.ttf
1477 DejaVuSansMono-BoldOblique.ttf 1518 DejaVuSansMono-BoldOblique.ttf
1478 ); 1519 );
1479 1520
1480 CFClient::add_font $_ for @fonts; 1521 CFClient::add_font $_ for @fonts;
1481 1522
1482 $FONT_PROP = new_from_file CFClient::Font $fonts[0]; 1523 $FONT_PROP = new_from_file CFClient::Font $fonts[0];
1483 $FONT_FIXED = new_from_file CFClient::Font $fonts[1]; 1524 $FONT_FIXED = new_from_file CFClient::Font $fonts[1];
1484 1525
1485 $FONT_PROP->make_default; 1526 $FONT_PROP->make_default;
1486} 1527 }
1487 1528
1488video_init; 1529 video_init;
1489audio_init; 1530 audio_init;
1531}
1490 1532
1491Event::loop; 1533Event::loop;
1492 1534
1493END { CFClient::SDL_Quit } 1535END { CFClient::SDL_Quit }
1494 1536

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines