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.193 by root, Sat Apr 29 16:17:10 2006 UTC vs.
Revision 1.205 by root, Tue May 9 16:22:44 2006 UTC

76our $MAPWIDGET; 76our $MAPWIDGET;
77our $BUTTONBAR; 77our $BUTTONBAR;
78our $LOGVIEW; 78our $LOGVIEW;
79our $CONSOLE; 79our $CONSOLE;
80our $METASERVER; 80our $METASERVER;
81our $LOGIN_BUTTON;
81 82
82our $FLOORBOX; 83our $FLOORBOX;
83our $GAUGES; 84our $GAUGES;
84our $STATWIDS; 85our $STATWIDS;
85 86
111 status "logging in..."; 112 status "logging in...";
112 113
113 my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; 114 my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32;
114 115
115 $MAPCACHE = CFClient::db_table "mapcache_$CFG->{host}"; 116 $MAPCACHE = CFClient::db_table "mapcache_$CFG->{host}";
116
117 $MAP = new CFClient::Map $mapsize, $mapsize; 117 $MAP = new CFClient::Map $mapsize, $mapsize;
118 118
119 my ($host, $port) = split /:/, $CFG->{host}; 119 my ($host, $port) = split /:/, $CFG->{host};
120 120
121 $CONN = new conn 121 $CONN = eval {
122 new conn
122 host => $host, 123 host => $host,
123 port => $port || 13327, 124 port => $port || 13327,
124 user => $CFG->{user}, 125 user => $CFG->{user},
125 pass => $CFG->{password}, 126 pass => $CFG->{password},
126 mapw => $mapsize, 127 mapw => $mapsize,
127 maph => $mapsize, 128 maph => $mapsize,
129 ;
128 ; 130 };
129 131
132 if ($CONN) {
133 $LOGIN_BUTTON->set_text ("Logout");
134
130 status "login successful"; 135 status "login successful";
131 136
132 CFClient::lowdelay fileno $CONN->{fh}; 137 CFClient::lowdelay fileno $CONN->{fh};
138 } else {
139 status "unable to connect";
140 stop_game();
141 }
133} 142}
134 143
135sub stop_game { 144sub stop_game {
145 return unless $CONN;
146
147 status "connection closed";
148 $LOGIN_BUTTON->set_text ("Login");
149 $CONN->destroy;
150 $CONN = 0; # false, does not autovivify
151
152 undef $MAPCACHE;
136 undef $CONN; 153 undef $MAP;
137} 154}
138 155
139sub client_setup { 156sub client_setup {
140 my $dialog = new CFClient::UI::FancyFrame 157 my $dialog = new CFClient::UI::FancyFrame
141 title => "Client Setup", 158 title => "Client Setup",
565 582
566} 583}
567 584
568sub metaserver_dialog { 585sub metaserver_dialog {
569 my $dialog = new CFClient::UI::FancyFrame 586 my $dialog = new CFClient::UI::FancyFrame
570 title => "Metaserver", 587 title => "Server List",
571 child => (my $vbox = new CFClient::UI::VBox); 588 child => (my $vbox = new CFClient::UI::VBox);
572 589
573 $vbox->add ($dialog->{table} = new CFClient::UI::Table); 590 $vbox->add ($dialog->{table} = new CFClient::UI::Table);
574 591
575 $dialog 592 $dialog
677 694
678 $METASERVER = metaserver_dialog; 695 $METASERVER = metaserver_dialog;
679 696
680 $vbox->add (new CFClient::UI::Flopper 697 $vbox->add (new CFClient::UI::Flopper
681 expand => 1, 698 expand => 1,
682 text => "Metaserver", 699 text => "Server List",
683 other => $METASERVER, 700 other => $METASERVER,
684 tooltip => "Show a list of avaible crossfire servers", 701 tooltip => "Show a list of available crossfire servers",
685 connect_open => sub { 702 connect_open => sub {
686 update_metaserver $HOST; 703 update_metaserver $HOST;
687 } 704 }
688 ); 705 );
689 } 706 }
720 737
721 $CFG->{mapsize} = $self->{range}[0] = $value = int $value; 738 $CFG->{mapsize} = $self->{range}[0] = $value = int $value;
722 }, 739 },
723 ); 740 );
724 741
725 $table->add (1, 8, new CFClient::UI::Button expand => 1, align => 0, text => "Login", connect_activate => sub { 742 $table->add (1, 8, $LOGIN_BUTTON = new CFClient::UI::Button
743 expand => 1,
744 align => 0,
745 text => "Login",
746 connect_activate => sub {
747 $CONN ? stop_game
726 start_game; 748 : start_game;
749 },
727 }); 750 );
728 751
729 $dialog 752 $dialog
730} 753}
731 754
732sub message_window { 755sub message_window {
783 $window 806 $window
784} 807}
785 808
786sub make_inventory_window { 809sub make_inventory_window {
787 my $invwin = new CFClient::UI::FancyFrame user_w => 300, user_h => 300, title => "Inventory"; 810 my $invwin = new CFClient::UI::FancyFrame user_w => 300, user_h => 300, title => "Inventory";
788 $invwin->add (my $hb = new CFClient::UI::HBox);
789 $hb->add ($INV = new CFClient::UI::Inventory expand => 1); 811 $invwin->add ($INV = new CFClient::UI::Inventory expand => 1);
790 $hb->add (my $rng = new CFClient::UI::Slider vertical => 1);
791 $INV->set_range ($rng);
792 $invwin 812 $invwin
793} 813}
794 814
795sub sdl_init { 815sub sdl_init {
796 CFClient::SDL_Init 816 CFClient::SDL_Init
798} 818}
799 819
800sub video_init { 820sub video_init {
801 sdl_init; 821 sdl_init;
802 822
823 $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} >= @SDL_MODES;
824
803 ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; 825 ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] };
804 $FULLSCREEN = $CFG->{fullscreen}; 826 $FULLSCREEN = $CFG->{fullscreen};
805 $FAST = $CFG->{fast}; 827 $FAST = $CFG->{fast};
806 828
807 CFClient::SDL_SetVideoMode $WIDTH, $HEIGHT, $FULLSCREEN 829 CFClient::SDL_SetVideoMode $WIDTH, $HEIGHT, $FULLSCREEN
808 or die "SDL_SetVideoMode failed!\n"; 830 or die "SDL_SetVideoMode failed!\n";
809 831
810 $SDL_ACTIVE = 1; 832 $SDL_ACTIVE = 1;
811
812 $LAST_REFRESH = time - 0.01; 833 $LAST_REFRESH = time - 0.01;
813 834
814 CFClient::gl_init; 835 CFClient::gl_init;
815 836
816 $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize}; 837 $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize};
817 838
839 $CFClient::UI::ROOT->configure (0, 0, $WIDTH, $HEIGHT);#d#
840
818 ############################################################################# 841 #############################################################################
819 842
843 if ($DEBUG_STATUS) {
844 # reconfigure all widgets
845 $CFClient::UI::ROOT->reconfigure;
846
847 } else {
848 # create the widgets
849
820 $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100; 850 $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100;
821 $DEBUG_STATUS->show; 851 $DEBUG_STATUS->show;
822 852
823 $STATUS_LINE = new CFClient::UI::Label 853 $STATUS_LINE = new CFClient::UI::Label
824 padding => 0, 854 padding => 0,
825 y => $HEIGHT - $FONTSIZE * 1.8; 855 y => $HEIGHT - $FONTSIZE * 1.8;
826 $STATUS_LINE->show; 856 $STATUS_LINE->show;
827 857
828 $ALT_ENTER_MESSAGE = new CFClient::UI::Label 858 $ALT_ENTER_MESSAGE = new CFClient::UI::Label
829 padding => 0, 859 padding => 0,
830 fontsize => 0.8, 860 fontsize => 0.8,
831 markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; 861 markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode";
832 $ALT_ENTER_MESSAGE->show; 862 $ALT_ENTER_MESSAGE->show;
833 $ALT_ENTER_MESSAGE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h}); 863 $ALT_ENTER_MESSAGE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h});
834 864
835 CFClient::UI::FancyFrame->new ( 865 CFClient::UI::FancyFrame->new (
836 border_bg => [1, 1, 1, 192/255], 866 border_bg => [1, 1, 1, 192/255],
837 bg => [1, 1, 1, 0], 867 bg => [1, 1, 1, 0],
838 child => ($MAPMAP = new CFClient::MapWidget::MapMap), 868 child => ($MAPMAP = new CFClient::MapWidget::MapMap),
839 )->show; 869 )->show;
840 870
841 $MAPWIDGET = new CFClient::MapWidget; 871 $MAPWIDGET = new CFClient::MapWidget;
842 $MAPWIDGET->connect (activate_console => sub { 872 $MAPWIDGET->connect (activate_console => sub {
843 my ($mapwidget, $preset) = @_; 873 my ($mapwidget, $preset) = @_;
844 874
845 if ($CONSOLE) { 875 if ($CONSOLE) {
846 $CONSOLE->{input}->{auto_activated} = 1; 876 $CONSOLE->{input}->{auto_activated} = 1;
847 $CONSOLE->{input}->focus_in; 877 $CONSOLE->{input}->focus_in;
848 878
849 if ($preset && $CONSOLE->{input}->get_text eq '') { 879 if ($preset && $CONSOLE->{input}->get_text eq '') {
850 $CONSOLE->{input}->set_text ($preset); 880 $CONSOLE->{input}->set_text ($preset);
881 }
851 } 882 }
852 } 883 });
853 });
854 $MAPWIDGET->show; 884 $MAPWIDGET->show;
855 $MAPWIDGET->focus_in; 885 $MAPWIDGET->focus_in;
856 886
857 $BUTTONBAR = new CFClient::UI::HBox; 887 $BUTTONBAR = new CFClient::UI::HBox;
858 888
859 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Client Setup", other => client_setup); 889 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Client Setup", other => client_setup);
860 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Server Setup", other => server_setup); 890 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Server Setup", other => server_setup);
861 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => message_window); 891 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => message_window);
862 892
863 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 893 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
864 894
865 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window); 895 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window);
866 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Inventory", other => make_inventory_window); 896 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Inventory", other => make_inventory_window);
867 897
868 $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub { 898 $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub {
869 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; 899 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc";
870 status "Configuration Saved"; 900 status "Configuration Saved";
871 }); 901 });
872 902
873 $BUTTONBAR->show; 903 $BUTTONBAR->show;
874 904
875 $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup 905 $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup
906 }
876} 907}
877 908
878sub video_shutdown { 909sub video_shutdown {
879 $CFClient::UI::ROOT->{children} = [];
880 undef $CFClient::UI::GRAB;
881 undef $CFClient::UI::HOVER;
882 undef $SDL_ACTIVE; 910 undef $SDL_ACTIVE;
883} 911}
884 912
885my @bgmusic = qw(game1.ogg game2.ogg game3.ogg game5.ogg game6.ogg ross1.ogg ross2.ogg ross3.ogg ross4.ogg ross5.ogg); #d# 913my @bgmusic = qw(game1.ogg game2.ogg game3.ogg game5.ogg game6.ogg ross1.ogg ross2.ogg ross3.ogg ross4.ogg ross5.ogg); #d#
886my $bgmusic;#TODO#hack#d# 914my $bgmusic;#TODO#hack#d#
915
916sub audio_channel_finished {
917 my ($channel) = @_;
918
919 warn "channel $channel finished\n";#d#
920}
887 921
888sub audio_music_finished { 922sub audio_music_finished {
889 return unless $CFG->{bgm_enable}; 923 return unless $CFG->{bgm_enable};
890 924
891 # TODO: hack, do play loop and mood music 925 # TODO: hack, do play loop and mood music
895 push @bgmusic, shift @bgmusic; 929 push @bgmusic, shift @bgmusic;
896} 930}
897 931
898sub audio_init { 932sub audio_init {
899 if ($CFG->{audio_enable}) { 933 if ($CFG->{audio_enable}) {
900 if (open my $fh, "<:utf8", CFClient::find_rcfile "sounds/config") { 934 if (open my $fh, "<", CFClient::find_rcfile "sounds/config") {
901 $SDL_MIXER = !CFClient::Mix_OpenAudio; 935 $SDL_MIXER = !CFClient::Mix_OpenAudio;
902 CFClient::Mix_AllocateChannels 8; 936 CFClient::Mix_AllocateChannels 8;
903 CFClient::MixMusic::volume $CFG->{bgm_volume} * 128; 937 CFClient::MixMusic::volume $CFG->{bgm_volume} * 128;
904 938
905 audio_music_finished; 939 audio_music_finished;
1316 1350
1317 for my $skill (values %{$self->{skill_info}}) { 1351 for my $skill (values %{$self->{skill_info}}) {
1318 $MAPWIDGET->add_command ("ready_skill $skill", "Ready the skill '$skill'"); 1352 $MAPWIDGET->add_command ("ready_skill $skill", "Ready the skill '$skill'");
1319 $MAPWIDGET->add_command ("use_skill $skill", "Immediately use the skill '$skill'"); 1353 $MAPWIDGET->add_command ("use_skill $skill", "Immediately use the skill '$skill'");
1320 } 1354 }
1355
1356 $MAPWIDGET->add_command ("pet\\_mode defend", "Tell pets to stay close to you and defend you");
1357 $MAPWIDGET->add_command ("pet\\_mode arena", "Same as petmode attack, but also attack other players");
1358 $MAPWIDGET->add_command ("pet\\_mode sad", "Search &amp; Destroy - tell pets to roam about and attack enemies");
1359 $MAPWIDGET->add_command ("kill\\_pets", "kill your pets");
1360}
1361
1362sub conn::eof {
1363 stop_game;
1321} 1364}
1322 1365
1323sub update_floorbox { 1366sub update_floorbox {
1324 $CFClient::UI::ROOT->on_refresh ($FLOORBOX => sub { 1367 $CFClient::UI::ROOT->on_refresh ($FLOORBOX => sub {
1368 return unless $CONN;
1369
1325 $FLOORBOX->clear; 1370 $FLOORBOX->clear;
1326 $FLOORBOX->add (new CFClient::UI::Empty expand => 1); 1371 $FLOORBOX->add (new CFClient::UI::Empty expand => 1);
1327 1372
1328 # we basically have to use the same sorting as everybody else 1373 # we basically have to use the same sorting as everybody else
1329 for my $item (@{ $CONN->{container}{0} }) { 1374 $FLOORBOX->add (
1330 my $desc = $item->{nrof} < 2 1375 map +(new CFClient::UI::InventoryItem item => $_),
1331 ? $item->{name} 1376 @{ $CONN->{container}{0} }
1332 : "$item->{nrof} $item->{name_pl}";
1333 # todo: animation widget, face widget, weight(?) etc.
1334 $FLOORBOX->add (my $hbox = new CFClient::UI::HBox
1335 tooltip => (CFClient::UI::Label->escape ($desc)
1336 . "\n<small>leftclick - pick up\nmiddle click - apply\nrightclick - menu</small>"),
1337 can_hover => 1,
1338 can_events => 1,
1339 connect_button_down => sub {
1340 my ($self, $ev, $x, $y) = @_;
1341
1342 # todo: maybe put examine on 1? but should just be a tooltip :(
1343 if ($ev->{button} == 1) {
1344 $CONN->send ("move $CONN->{player}{tag} $item->{tag} 0");
1345 } elsif ($ev->{button} == 2) {
1346 $CONN->send ("apply $item->{tag}");
1347 } elsif ($ev->{button} == 3) {
1348 CFClient::UI::Menu->new (
1349 items => [
1350 ["examine", sub { $CONN->send ("examine $item->{tag}") }],
1351 [
1352 $item->{flags} & Crossfire::Protocol::F_LOCKED ? "lock" : "unlock",
1353 sub { $CONN->send ("lock $item->{tag}") },
1354 ],
1355 ["mark", sub { $CONN->send ("mark $item->{tag}") }],
1356 ["apply", sub { $CONN->send ("apply $item->{tag}") }],
1357 ],
1358 )->popup ($ev);
1359 }
1360
1361 1
1362 },
1363 ); 1377 );
1364
1365 $hbox->add (new CFClient::UI::Face
1366 can_events => 0,
1367 face => $item->{face},
1368 anim => $item->{anim},
1369 animspeed => $item->{animspeed},
1370 );
1371
1372 $hbox->add (new CFClient::UI::Label
1373 can_events => 0,
1374 text => $desc,
1375 );
1376 }
1377 }); 1378 });
1378 refresh; 1379 refresh;
1379} 1380}
1380 1381
1381sub conn::container_add { 1382sub conn::container_add {
1382 my ($self, $id, $items) = @_; 1383 my ($self, $tag, $items) = @_;
1383 1384
1384 update_floorbox if $id == 0; 1385 update_floorbox if $tag == 0;
1385 if ($self->{player}{tag} == $id) { 1386
1386 $INV->set_items ($self->{container}{$self->{player}{tag}}); 1387 $INV->set_items ($self->{container}{$self->{player}{tag}})
1387 } 1388 if $tag == $self->{player}{tag};
1389
1388 # $self-<{player}{tag} => player inv 1390 # $self-<{player}{tag} => player inv
1389 #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}};
1390} 1392}
1391 1393
1392sub conn::container_clear { 1394sub conn::container_clear {
1393 my ($self, $id) = @_; 1395 my ($self, $tag) = @_;
1394 1396
1395 update_floorbox if $id == 0; 1397 update_floorbox if $tag == 0;
1396 if ($self->{player}{tag} == $id) { 1398
1397 $INV->set_items ($self->{container}{$id}); 1399 $INV->set_items ($self->{container}{$tag})
1398 } 1400 if $tag == $self->{player}{tag};
1399 1401
1400# use PApp::Util; warn PApp::Util::dumpval $self->{container}{0}; 1402# use PApp::Util; warn PApp::Util::dumpval $self->{container}{0};
1401} 1403}
1402 1404
1403sub conn::item_delete { 1405sub conn::item_delete {
1404 my ($self, @items) = @_; 1406 my ($self, @items) = @_;
1405 1407
1406 for (@items) { 1408 for (@items) {
1407 update_floorbox if $_->{container} == 0; 1409 update_floorbox if $_->{container} == 0;
1408 if ($self->{player}{tag} == $_->{container}) { 1410
1409 $INV->set_items ($self->{container}{$_->{container}}); 1411 $INV->set_items ($self->{container}{$_->{container}})
1410 } 1412 if $_->{container} == $self->{player}{tag};
1411 } 1413 }
1412} 1414}
1413 1415
1414sub conn::item_update { 1416sub conn::item_update {
1415 my ($self, $item) = @_; 1417 my ($self, $item) = @_;
1416 1418
1417 update_floorbox if $item->{container} == 0; 1419 update_floorbox if $item->{container} == 0;
1418 if ($self->{player}{tag} == $item->{container}) { 1420
1419 $INV->set_items ($self->{container}{$item->{container}}); 1421 $INV->set_items ($self->{container}{$item->{container}})
1420 } 1422 if $item->{container} == $self->{player}{tag};
1421} 1423}
1422 1424
1423%SDL_CB = ( 1425%SDL_CB = (
1424 CFClient::SDL_QUIT => sub { 1426 CFClient::SDL_QUIT => sub {
1425 Event::unloop -1; 1427 Event::unloop -1;
1438 video_init; 1440 video_init;
1439 } else { 1441 } else {
1440 CFClient::UI::feed_sdl_key_down_event ($_[0]); 1442 CFClient::UI::feed_sdl_key_down_event ($_[0]);
1441 } 1443 }
1442 }, 1444 },
1443 CFClient::SDL_KEYUP => \&CFClient::UI::feed_sdl_key_up_event, 1445 CFClient::SDL_KEYUP => \&CFClient::UI::feed_sdl_key_up_event,
1444 CFClient::SDL_MOUSEMOTION => \&CFClient::UI::feed_sdl_motion_event, 1446 CFClient::SDL_MOUSEMOTION => \&CFClient::UI::feed_sdl_motion_event,
1445 CFClient::SDL_MOUSEBUTTONDOWN => \&CFClient::UI::feed_sdl_button_down_event, 1447 CFClient::SDL_MOUSEBUTTONDOWN => \&CFClient::UI::feed_sdl_button_down_event,
1446 CFClient::SDL_MOUSEBUTTONUP => \&CFClient::UI::feed_sdl_button_up_event, 1448 CFClient::SDL_MOUSEBUTTONUP => \&CFClient::UI::feed_sdl_button_up_event,
1447 CFClient::SDL_USEREVENT => \&audio_music_finished, 1449 CFClient::SDL_USEREVENT => sub {
1450 if ($_[0]{code} == 1) {
1451 audio_channel_finished $_[0]{data1};
1452 } elsif ($_[0]{code} == 0) {
1453 audio_music_finished;
1454 }
1455 },
1448); 1456);
1449 1457
1450############################################################################# 1458#############################################################################
1451 1459
1452$SIG{INT} = $SIG{TERM} = sub { exit }; 1460$SIG{INT} = $SIG{TERM} = sub { exit };
1453 1461
1454$TILECACHE = CFClient::db_table "tilecache";
1455$FACEMAP = CFClient::db_table "facemap";
1456
1457CFClient::read_cfg "$Crossfire::VARDIR/pclientrc";
1458
1459my %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
1482while (my ($k, $v) = each %DEF_CFG) {
1483 $CFG->{$k} = $v unless exists $CFG->{$k};
1484}
1485
1486sdl_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{ 1462{
1463 local $SIG{__DIE__} = sub { CFClient::fatal $_[0] };
1464
1465 CFClient::read_cfg "$Crossfire::VARDIR/pclientrc";
1466
1467 $TILECACHE = CFClient::db_table "tilecache";
1468 $FACEMAP = CFClient::db_table "facemap";
1469
1470 my %DEF_CFG = (
1471 sdl_mode => 0,
1472 width => 640,
1473 height => 480,
1474 fullscreen => 0,
1475 fast => 0,
1476 map_scale => 0.5,
1477 fow_enable => 1,
1478 fow_intensity => 0.45,
1479 fow_smooth => 0,
1480 gui_fontsize => 1,
1481 log_fontsize => 1,
1482 gauge_fontsize => 1,
1483 gauge_size => 0.35,
1484 stat_fontsize => 1,
1485 mapsize => 100,
1486 host => "crossfire.schmorp.de",
1487 say_command => 'say',
1488 audio_enable => 1,
1489 bgm_enable => 1,
1490 bgm_volume => 0.25,
1491 );
1492
1493 while (my ($k, $v) = each %DEF_CFG) {
1494 $CFG->{$k} = $v unless exists $CFG->{$k};
1495 }
1496
1497 sdl_init;
1498
1499 @SDL_MODES = reverse
1500 grep $_->[0] >= 640 && $_->[1] >= 480,
1501 CFClient::SDL_ListModes;
1502
1503 @SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)";
1504
1505 $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES;
1506
1507 {
1497 my @fonts = map CFClient::find_rcfile "fonts/$_", qw( 1508 my @fonts = map CFClient::find_rcfile "fonts/$_", qw(
1498 DejaVuSans.ttf 1509 DejaVuSans.ttf
1499 DejaVuSansMono.ttf 1510 DejaVuSansMono.ttf
1500 DejaVuSans-Bold.ttf 1511 DejaVuSans-Bold.ttf
1501 DejaVuSansMono-Bold.ttf 1512 DejaVuSansMono-Bold.ttf
1502 DejaVuSans-Oblique.ttf 1513 DejaVuSans-Oblique.ttf
1503 DejaVuSansMono-Oblique.ttf 1514 DejaVuSansMono-Oblique.ttf
1504 DejaVuSans-BoldOblique.ttf 1515 DejaVuSans-BoldOblique.ttf
1505 DejaVuSansMono-BoldOblique.ttf 1516 DejaVuSansMono-BoldOblique.ttf
1506 ); 1517 );
1507 1518
1508 CFClient::add_font $_ for @fonts; 1519 CFClient::add_font $_ for @fonts;
1509 1520
1510 $FONT_PROP = new_from_file CFClient::Font $fonts[0]; 1521 $FONT_PROP = new_from_file CFClient::Font $fonts[0];
1511 $FONT_FIXED = new_from_file CFClient::Font $fonts[1]; 1522 $FONT_FIXED = new_from_file CFClient::Font $fonts[1];
1512 1523
1513 $FONT_PROP->make_default; 1524 $FONT_PROP->make_default;
1514} 1525 }
1515 1526
1516video_init; 1527 video_init;
1517audio_init; 1528 audio_init;
1529}
1518 1530
1519Event::loop; 1531Event::loop;
1520 1532
1521END { CFClient::SDL_Quit } 1533END { CFClient::SDL_Quit }
1522 1534

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines