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.203 by root, Mon May 8 20:55:49 2006 UTC vs.
Revision 1.216 by root, Mon May 15 17:45:31 2006 UTC

37use CFClient; 37use CFClient;
38use CFClient::UI; 38use CFClient::UI;
39use CFClient::MapWidget; 39use 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
59our $NOW; 60our $NOW;
60 61
61our $CFG; 62our $CFG;
62our $CONN; 63our $CONN;
63our $FAST; # fast, low-quality mode, possibly useful for software-rendering 64our $FAST; # fast, low-quality mode, possibly useful for software-rendering
65
66our $WANT_REFRESH;
67our $CAN_REFRESH;
64 68
65our @SDL_MODES; 69our @SDL_MODES;
66our $WIDTH; 70our $WIDTH;
67our $HEIGHT; 71our $HEIGHT;
68our $FULLSCREEN; 72our $FULLSCREEN;
90our $SDL_MIXER; 94our $SDL_MIXER;
91our @SOUNDS; # event => file mapping 95our @SOUNDS; # event => file mapping
92our %AUDIO_CHUNKS; # audio files 96our %AUDIO_CHUNKS; # audio files
93 97
94our $ALT_ENTER_MESSAGE; 98our $ALT_ENTER_MESSAGE;
95our $STATUS_LINE; 99our $STATUSBOX;
96our $DEBUG_STATUS; 100our $DEBUG_STATUS;
97 101
98our $INVWIN; 102our $INVWIN;
99our $INV; 103our $INV;
100 104
101sub status { 105sub status {
102 $STATUS_LINE->set_text ($_[0]); 106 $STATUSBOX->add ($_[0], pri => -10, group => "status", timeout => 20, fg => [1, 1, 0, 1]);
103 $STATUS_LINE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $STATUS_LINE->{h});
104} 107}
105 108
106sub debug { 109sub debug {
107 $DEBUG_STATUS->set_text ($_[0]); 110 $DEBUG_STATUS->set_text ($_[0]);
108 $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);
109} 113}
110 114
111sub start_game { 115sub start_game {
112 status "logging in..."; 116 status "logging in...";
113 117
160 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); 164 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]);
161 165
162 $table->add (0, 0, new CFClient::UI::Label valign => 0, align => 1, text => "Video Mode"); 166 $table->add (0, 0, new CFClient::UI::Label valign => 0, align => 1, text => "Video Mode");
163 $table->add (1, 0, my $hbox = new CFClient::UI::HBox); 167 $table->add (1, 0, my $hbox = new CFClient::UI::HBox);
164 168
165 $hbox->add (my $mode_slider = new CFClient::UI::Slider expand => 1, req_w => 100, range => [$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1]); 169 $hbox->add (my $mode_slider = new CFClient::UI::Slider expand => 1, req_w => 100, range => [$CFG->{sdl_mode}, 0, $#SDL_MODES, 1, 1]);
166 $hbox->add (my $mode_label = new CFClient::UI::Label align => 0, valign => 0, height => 0.8, template => "9999x9999"); 170 $hbox->add (my $mode_label = new CFClient::UI::Label align => 0, valign => 0, height => 0.8, template => "9999x9999");
167 171
168 $mode_slider->connect (changed => sub { 172 $mode_slider->connect (changed => sub {
169 my ($self, $value) = @_; 173 my ($self, $value) = @_;
170 174
195 } 199 }
196 ); 200 );
197 201
198 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Map Scale"); 202 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Map Scale");
199 $table->add (1, $row++, new CFClient::UI::Slider 203 $table->add (1, $row++, new CFClient::UI::Slider
200 range => [$CFG->{map_scale}, 0.25, 2, 0.05], 204 range => [$CFG->{map_scale}, 0.25, 2, 0.05, 0.05],
201 tooltip => "Enlarge or shrink the displayed map", 205 tooltip => "Enlarge or shrink the displayed map",
202 connect_changed => sub { 206 connect_changed => sub {
203 my ($self, $value) = @_; 207 my ($self, $value) = @_;
204 $CFG->{map_scale} = 0.05 * int $value / 0.05; 208 $CFG->{map_scale} = $value;
205 } 209 }
206 ); 210 );
207 211
208 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Fog of War"); 212 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Fog of War");
209 $table->add (1, $row++, new CFClient::UI::CheckBox 213 $table->add (1, $row++, new CFClient::UI::CheckBox
236 } 240 }
237 ); 241 );
238 242
239 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "GUI Fontsize"); 243 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "GUI Fontsize");
240 $table->add (1, $row++, new CFClient::UI::Slider 244 $table->add (1, $row++, new CFClient::UI::Slider
241 range => [$CFG->{gui_fontsize}, 0.5, 2, 0.1], 245 range => [$CFG->{gui_fontsize}, 0.5, 2, 0.1, 0.1],
242 tooltip => "The font size used by most GUI elements", 246 tooltip => "The font size used by most GUI elements",
243 connect_changed => sub { 247 connect_changed => sub { $CFG->{gui_fontsize} = $_[1] },
244 $CFG->{gui_fontsize} = 0.1 * int $_[1] * 10;
245# $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize};
246 }
247 ); 248 );
248 249
249 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Server Log Fontsize"); 250 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Server Log Fontsize");
250 $table->add (1, $row++, new CFClient::UI::Slider 251 $table->add (1, $row++, new CFClient::UI::Slider
251 range => [$CFG->{log_fontsize}, 0.5, 2, 0.1], 252 range => [$CFG->{log_fontsize}, 0.5, 2, 0.1, 0.1],
252 tooltip => "The font size used by the server log window only", 253 tooltip => "The font size used by the server log window only",
253 connect_changed => sub { 254 connect_changed => sub { $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = $_[1]) },
254 $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = 0.1 * int $_[1] * 10);
255 }
256 ); 255 );
257 256
258 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Stats Fontsize"); 257 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Stats Fontsize");
259 258
260 $table->add (1, $row++, new CFClient::UI::Slider 259 $table->add (1, $row++, new CFClient::UI::Slider
261 range => [$CFG->{stat_fontsize}, 0.5, 2, 0.1], 260 range => [$CFG->{stat_fontsize}, 0.5, 2, 0.1, 0.1],
262 tooltip => "The font size used by the statistics window only", 261 tooltip => "The font size used by the statistics window only",
263 connect_changed => sub { 262 connect_changed => sub {
264 $CFG->{stat_fontsize} = 0.1 * int $_[1] * 10; 263 $CFG->{stat_fontsize} = $_[1];
265 &set_stats_window_fontsize; 264 &set_stats_window_fontsize;
266 } 265 }
267 ); 266 );
268 267
269 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Gauge size"); 268 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Gauge size");
270 $table->add (1, $row++, new CFClient::UI::Slider 269 $table->add (1, $row++, new CFClient::UI::Slider
271 range => [$CFG->{gauge_size}, 0.2, 0.8, 0.02], 270 range => [$CFG->{gauge_size}, 0.2, 0.8, 0.02],
272 tooltip => "Adjust the size of the stats gauges at the bottom right", 271 tooltip => "Adjust the size of the stats gauges at the bottom right",
273 connect_changed => sub { 272 connect_changed => sub {
274 $CFG->{gauge_size} = $_[1]; 273 $CFG->{gauge_size} = $_[1];
275 my $h = int $HEIGHT * $CFG->{gauge_size}; 274 $GAUGES->{win}->set_size ($WIDTH, int $HEIGHT * $CFG->{gauge_size});
276 $GAUGES->{win}->set_size ($WIDTH, $h);
277 $GAUGES->{win}->move (0, $HEIGHT - $h);
278 } 275 }
279 ); 276 );
280 277
281 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Gauge fontsize"); 278 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Gauge fontsize");
282 $table->add (1, $row++, new CFClient::UI::Slider 279 $table->add (1, $row++, new CFClient::UI::Slider
283 range => [$CFG->{gauge_fontsize}, 0.5, 2.0, 0.1], 280 range => [$CFG->{gauge_fontsize}, 0.5, 2.0, 0.1, 0.1],
284 tooltip => "Adjusts the fontsize of the gauges at the bottom right", 281 tooltip => "Adjusts the fontsize of the gauges at the bottom right",
285 connect_changed => sub { 282 connect_changed => sub {
286 $CFG->{gauge_fontsize} = 0.1 * int $_[1] * 10; 283 $CFG->{gauge_fontsize} = $_[1];
287 &set_gauge_window_fontsize; 284 &set_gauge_window_fontsize;
288 } 285 }
289 ); 286 );
290 287
291 $table->add (1, $row++, new CFClient::UI::Button 288 $table->add (1, $row++, new CFClient::UI::Button
365# local $GAUGES->{win}{parent};#d# 362# local $GAUGES->{win}{parent};#d#
366# use PApp::Util; open D, ">:utf8", "d"; print D PApp::Util::dumpval $GAUGES->{win}; close D; 363# use PApp::Util; open D, ">:utf8", "d"; print D PApp::Util::dumpval $GAUGES->{win}; close D;
367} 364}
368 365
369sub make_gauge_window { 366sub make_gauge_window {
370 my $gh = int ($HEIGHT * $CFG->{gauge_size}); 367 my $gh = int $HEIGHT * $CFG->{gauge_size};
371# my $gw = int ($WIDTH * $CFG->{gauge_w_size});
372 368
373 my $win = new CFClient::UI::Frame ( 369 my $win = new CFClient::UI::Frame (
374 y => $HEIGHT - $gh, x => 0, user_w => $WIDTH, user_h => $gh 370 req_y => -1,
371 user_w => $WIDTH,
372 user_h => $gh,
375 ); 373 );
374
376 $win->add (my $hbox = new CFClient::UI::HBox 375 $win->add (my $hbox = new CFClient::UI::HBox
377 children => [ 376 children => [
378 (new CFClient::UI::HBox expand => 1), 377 (new CFClient::UI::HBox expand => 1),
379 ($FLOORBOX = new CFClient::UI::VBox), 378 (new CFClient::UI::VBox children => [
379 (new CFClient::UI::Empty expand => 1),
380 (new CFClient::UI::Frame bg => [0, 0, 0, 0.4], child => ($FLOORBOX = new CFClient::UI::VBox)),
381 ]),
380 (my $vbox = new CFClient::UI::VBox), 382 (my $vbox = new CFClient::UI::VBox),
381 ], 383 ],
382 ); 384 );
383 385
384 $vbox->add (new CFClient::UI::HBox 386 $vbox->add (new CFClient::UI::HBox
727 ); 729 );
728 730
729 $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size"); 731 $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size");
730 $table->add (1, 7, new CFClient::UI::Slider 732 $table->add (1, 7, new CFClient::UI::Slider
731 req_w => 100, 733 req_w => 100,
732 range => [$CFG->{mapsize}, 10, 100 + 1, 1], 734 range => [$CFG->{mapsize}, 10, 100 + 1, 1, 1],
733 tooltip => "This is the size of the portion of the map update the server sends you. " 735 tooltip => "This is the size of the portion of the map update the server sends you. "
734 ."If you set this to a high value you will be able to see further for example.", 736 ."If you set this to a high value you will be able to see further for example.",
735 connect_changed => sub { 737 connect_changed => sub {
736 my ($self, $value) = @_; 738 my ($self, $value) = @_;
737 739
838 840
839 $CFClient::UI::ROOT->configure (0, 0, $WIDTH, $HEIGHT);#d# 841 $CFClient::UI::ROOT->configure (0, 0, $WIDTH, $HEIGHT);#d#
840 842
841 ############################################################################# 843 #############################################################################
842 844
843 if ($DEBUG_STATUS) { 845 unless ($DEBUG_STATUS) {
844 # reconfigure all widgets
845 $CFClient::UI::ROOT->reconfigure;
846
847 } else {
848 # create the widgets 846 # create the widgets
849 847
850 $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100; 848 $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100, req_x => -1;
851 $DEBUG_STATUS->show; 849 $DEBUG_STATUS->show;
852 850
853 $STATUS_LINE = new CFClient::UI::Label 851 $STATUSBOX = new CFClient::UI::Statusbox;
854 padding => 0, 852 $STATUSBOX->add ("Use <b>Alt-Enter</b> to toggle fullscreen mode", pri => -100, color => [1, 1, 1, 0.8]);
855 y => $HEIGHT - $FONTSIZE * 1.8;
856 $STATUS_LINE->show;
857 853
858 $ALT_ENTER_MESSAGE = new CFClient::UI::Label 854 (new CFClient::UI::Frame
859 padding => 0, 855 bg => [0, 0, 0, 0.4],
860 fontsize => 0.8, 856 req_y => -1,
861 markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; 857 child => $STATUSBOX,
862 $ALT_ENTER_MESSAGE->show; 858 )->show;
863 $ALT_ENTER_MESSAGE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h});
864 859
865 CFClient::UI::FancyFrame->new ( 860 CFClient::UI::FancyFrame->new (
866 border_bg => [1, 1, 1, 192/255], 861 border_bg => [1, 1, 1, 192/255],
867 bg => [1, 1, 1, 0], 862 bg => [1, 1, 1, 0],
868 child => ($MAPMAP = new CFClient::MapWidget::MapMap), 863 child => ($MAPMAP = new CFClient::MapWidget::MapMap),
900 status "Configuration Saved"; 895 status "Configuration Saved";
901 }); 896 });
902 897
903 $BUTTONBAR->show; 898 $BUTTONBAR->show;
904 899
900 $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]);
901
902 # delay till geometry is constant
903 $CFClient::UI::ROOT->on_post_alloc (startup => sub {
905 $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup 904 $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup
905 my $widget = $GAUGES->{win};
906 $widget->move (0, $HEIGHT - $widget->{h});#d# to in toplevel
907 });
908 force_refresh ();
906 } 909 }
907} 910}
908 911
909sub video_shutdown { 912sub video_shutdown {
910 undef $SDL_ACTIVE; 913 undef $SDL_ACTIVE;
966} 969}
967 970
968my %animate_object; 971my %animate_object;
969my $animate_timer; 972my $animate_timer;
970 973
971my $want_refresh;
972my $can_refresh;
973
974my $fps = 9; 974my $fps = 9;
975 975
976sub force_refresh { 976sub force_refresh {
977 $fps = $fps * 0.95 + 1 / ($NOW - $LAST_REFRESH) * 0.05; 977 $fps = $fps * 0.95 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.05;
978 debug sprintf "%3.2f", $fps; 978 debug sprintf "%3.2f", $fps;
979 979
980 $want_refresh = 0;
981 $can_refresh = 0;
982
983 $CFClient::UI::ROOT->draw; 980 $CFClient::UI::ROOT->draw;
984
985 CFClient::SDL_GL_SwapBuffers; 981 CFClient::SDL_GL_SwapBuffers;
986 982
983 $WANT_REFRESH = 0;
984 $CAN_REFRESH = 0;
987 $LAST_REFRESH = $NOW; 985 $LAST_REFRESH = $NOW;
988} 986}
989 987
990my $refresh_watcher = Event->timer (after => 0, hard => 1, interval => 1 / $MAX_FPS, cb => sub { 988my $refresh_watcher = Event->timer (after => 0, hard => 1, interval => 1 / $MAX_FPS, cb => sub {
991 $NOW = time; 989 $NOW = time;
993 ($SDL_CB{$_->{type}} || sub { warn "unhandled event $_->{type}" })->($_) 991 ($SDL_CB{$_->{type}} || sub { warn "unhandled event $_->{type}" })->($_)
994 for CFClient::SDL_PollEvent; 992 for CFClient::SDL_PollEvent;
995 993
996 if (%animate_object) { 994 if (%animate_object) {
997 $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; 995 $_->animate ($LAST_REFRESH - $NOW) for values %animate_object;
998 $want_refresh++; 996 $WANT_REFRESH++;
999 } 997 }
1000 998
1001 if ($want_refresh) { 999 if ($WANT_REFRESH) {
1002 force_refresh; 1000 force_refresh;
1003 } else { 1001 } else {
1004 $can_refresh = 1; 1002 $CAN_REFRESH = 1;
1005 } 1003 }
1006}); 1004});
1007
1008sub refresh {
1009 $want_refresh++;
1010}
1011 1005
1012sub animation_start { 1006sub animation_start {
1013 my ($widget) = @_; 1007 my ($widget) = @_;
1014 $animate_object{$widget} = $widget; 1008 $animate_object{$widget} = $widget;
1015} 1009}
1327 [0.55, 0.41, 0.13], 1321 [0.55, 0.41, 0.13],
1328 [0.99, 0.77, 0.26], 1322 [0.99, 0.77, 0.26],
1329 [0.74, 0.65, 0.41], 1323 [0.74, 0.65, 0.41],
1330 ); 1324 );
1331 1325
1326 my $time = sprintf "%02d:%02d:%02d", (localtime time)[2,1,0];
1327
1328 $text =~ s/&/&amp;/g; $text =~ s/</&lt;/g;
1329 $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g;
1330 $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g;
1331
1332 $LOGVIEW->add_paragraph ($color[$color], $text); 1332 $LOGVIEW->add_paragraph ($color[$color],
1333 join "\n", map "$time $_", split /\n/, $text);
1334
1335 $STATUSBOX->add ($text,
1336 group => $text,
1337 fg => $color[$color],
1338 timeout => 60,
1339 tooltip_font => $::FONT_FIXED,
1340 );
1341}
1342
1343sub conn::drawextinfo {
1344 my ($self, $color, $type, $subtype, $message) = @_;
1345
1346 $self->drawinfo ($color, $message);
1333} 1347}
1334 1348
1335sub conn::spell_add { 1349sub conn::spell_add {
1336 my ($self, $spell) = @_; 1350 my ($self, $spell) = @_;
1337 1351
1368 return unless $CONN; 1382 return unless $CONN;
1369 1383
1370 $FLOORBOX->clear; 1384 $FLOORBOX->clear;
1371 $FLOORBOX->add (new CFClient::UI::Empty expand => 1); 1385 $FLOORBOX->add (new CFClient::UI::Empty expand => 1);
1372 1386
1373 # we basically have to use the same sorting as everybody else 1387 my $count = 4;
1374 for my $item (@{ $CONN->{container}{0} }) { 1388 for (@{ $CONN->{container}{0} }) {
1389 if (--$count) {
1375 $FLOORBOX->add (new CFClient::UI::InventoryItem item => $item); 1390 $FLOORBOX->add (new CFClient::UI::InventoryItem item => $_);
1391 } else {
1392 $FLOORBOX->add (new CFClient::UI::Label text => "More...");
1393 last;
1394 }
1376 } 1395 }
1377 }); 1396 });
1378 refresh; 1397
1398 $WANT_REFRESH++;
1379} 1399}
1380 1400
1381sub conn::container_add { 1401sub conn::container_add {
1382 my ($self, $tag, $items) = @_; 1402 my ($self, $tag, $items) = @_;
1383 1403
1416 my ($self, $item) = @_; 1436 my ($self, $item) = @_;
1417 1437
1418 update_floorbox if $item->{container} == 0; 1438 update_floorbox if $item->{container} == 0;
1419 1439
1420 $INV->set_items ($self->{container}{$item->{container}}) 1440 $INV->set_items ($self->{container}{$item->{container}})
1421 if $item->{container}; == $self->{player}{tag}; 1441 if $item->{container} == $self->{player}{tag};
1422} 1442}
1423 1443
1424%SDL_CB = ( 1444%SDL_CB = (
1425 CFClient::SDL_QUIT => sub { 1445 CFClient::SDL_QUIT => sub {
1426 Event::unloop -1; 1446 Event::unloop -1;
1427 }, 1447 },
1428 CFClient::SDL_VIDEORESIZE => sub { 1448 CFClient::SDL_VIDEORESIZE => sub {
1429 }, 1449 },
1430 CFClient::SDL_VIDEOEXPOSE => \&refresh, 1450 CFClient::SDL_VIDEOEXPOSE => sub {
1451 $WANT_REFRESH++;
1452 },
1431 CFClient::SDL_ACTIVEEVENT => sub { 1453 CFClient::SDL_ACTIVEEVENT => sub {
1432# printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d# 1454# printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d#
1433 }, 1455 },
1434 CFClient::SDL_KEYDOWN => sub { 1456 CFClient::SDL_KEYDOWN => sub {
1435 if ($_[0]{mod} & CFClient::KMOD_ALT && $_[0]{sym} == 13) { 1457 if ($_[0]{mod} & CFClient::KMOD_ALT && $_[0]{sym} == 13) {
1456 1478
1457############################################################################# 1479#############################################################################
1458 1480
1459$SIG{INT} = $SIG{TERM} = sub { exit }; 1481$SIG{INT} = $SIG{TERM} = sub { exit };
1460 1482
1461CFClient::read_cfg "$Crossfire::VARDIR/pclientrc";
1462
1463$TILECACHE = CFClient::db_table "tilecache";
1464$FACEMAP = CFClient::db_table "facemap";
1465
1466my %DEF_CFG = (
1467 sdl_mode => 0,
1468 width => 640,
1469 height => 480,
1470 fullscreen => 0,
1471 fast => 0,
1472 map_scale => 0.5,
1473 fow_enable => 1,
1474 fow_intensity => 0.45,
1475 fow_smooth => 0,
1476 gui_fontsize => 1,
1477 log_fontsize => 1,
1478 gauge_fontsize => 1,
1479 gauge_size => 0.35,
1480 stat_fontsize => 1,
1481 mapsize => 100,
1482 host => "crossfire.schmorp.de",
1483 say_command => 'say',
1484 audio_enable => 1,
1485 bgm_enable => 1,
1486 bgm_volume => 0.25,
1487);
1488
1489while (my ($k, $v) = each %DEF_CFG) {
1490 $CFG->{$k} = $v unless exists $CFG->{$k};
1491}
1492
1493sdl_init;
1494
1495@SDL_MODES = reverse
1496 grep $_->[0] >= 640 && $_->[1] >= 480,
1497 CFClient::SDL_ListModes;
1498
1499@SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)";
1500
1501$CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES;
1502
1503{ 1483{
1484 local $SIG{__DIE__} = sub { CFClient::fatal $_[0] };
1485
1486 CFClient::read_cfg "$Crossfire::VARDIR/pclientrc";
1487
1488 $TILECACHE = CFClient::db_table "tilecache";
1489 $FACEMAP = CFClient::db_table "facemap";
1490
1491 my %DEF_CFG = (
1492 sdl_mode => 0,
1493 width => 640,
1494 height => 480,
1495 fullscreen => 0,
1496 fast => 0,
1497 map_scale => 0.5,
1498 fow_enable => 1,
1499 fow_intensity => 0.45,
1500 fow_smooth => 0,
1501 gui_fontsize => 1,
1502 log_fontsize => 1,
1503 gauge_fontsize=> 1,
1504 gauge_size => 0.35,
1505 stat_fontsize => 1,
1506 mapsize => 100,
1507 host => "crossfire.schmorp.de",
1508 say_command => 'say',
1509 audio_enable => 1,
1510 bgm_enable => 1,
1511 bgm_volume => 0.25,
1512 );
1513
1514 while (my ($k, $v) = each %DEF_CFG) {
1515 $CFG->{$k} = $v unless exists $CFG->{$k};
1516 }
1517
1518 sdl_init;
1519
1520 @SDL_MODES = reverse
1521 grep $_->[0] >= 640 && $_->[1] >= 480,
1522 CFClient::SDL_ListModes;
1523
1524 @SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)";
1525
1526 $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES;
1527
1528 {
1504 my @fonts = map CFClient::find_rcfile "fonts/$_", qw( 1529 my @fonts = map CFClient::find_rcfile "fonts/$_", qw(
1505 DejaVuSans.ttf 1530 DejaVuSans.ttf
1506 DejaVuSansMono.ttf 1531 DejaVuSansMono.ttf
1507 DejaVuSans-Bold.ttf 1532 DejaVuSans-Bold.ttf
1508 DejaVuSansMono-Bold.ttf 1533 DejaVuSansMono-Bold.ttf
1509 DejaVuSans-Oblique.ttf 1534 DejaVuSans-Oblique.ttf
1510 DejaVuSansMono-Oblique.ttf 1535 DejaVuSansMono-Oblique.ttf
1511 DejaVuSans-BoldOblique.ttf 1536 DejaVuSans-BoldOblique.ttf
1512 DejaVuSansMono-BoldOblique.ttf 1537 DejaVuSansMono-BoldOblique.ttf
1513 ); 1538 );
1514 1539
1515 CFClient::add_font $_ for @fonts; 1540 CFClient::add_font $_ for @fonts;
1516 1541
1542 CFClient::pango_init;
1543
1517 $FONT_PROP = new_from_file CFClient::Font $fonts[0]; 1544 $FONT_PROP = new_from_file CFClient::Font $fonts[0];
1518 $FONT_FIXED = new_from_file CFClient::Font $fonts[1]; 1545 $FONT_FIXED = new_from_file CFClient::Font $fonts[1];
1519 1546
1520 $FONT_PROP->make_default; 1547 $FONT_PROP->make_default;
1521} 1548 }
1522 1549
1523video_init; 1550 video_init;
1524audio_init; 1551 audio_init;
1552}
1525 1553
1526Event::loop; 1554Event::loop;
1527 1555
1528END { CFClient::SDL_Quit } 1556END { CFClient::SDL_Quit }
1529 1557

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines