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.121 by root, Mon Apr 17 09:33:12 2006 UTC vs.
Revision 1.140 by root, Wed Apr 19 06:06:46 2006 UTC

8 8
9use SDL; 9use SDL;
10use SDL::App; 10use SDL::App;
11use SDL::Event; 11use SDL::Event;
12use SDL::Surface; 12use SDL::Surface;
13
14use SDL::Mixer;
15use SDL::Sound;
16use SDL::Music;
17
13use SDL::OpenGL; 18use SDL::OpenGL;
14 19
15use Crossfire; 20use Crossfire;
16use Crossfire::Protocol; 21use Crossfire::Protocol;
17 22
49our $BUTTONBAR; 54our $BUTTONBAR;
50our $LOGVIEW; 55our $LOGVIEW;
51our $CONSOLE; 56our $CONSOLE;
52our $METASERVER; 57our $METASERVER;
53 58
59our $GAUGES;
60
54our $SDL_ACTIVE; 61our $SDL_ACTIVE;
55our $SDL_EV; 62our $SDL_EV;
56our %SDL_CB; 63our %SDL_CB;
57 64
65our $SDL_MIXER;
66our @SOUNDS; # event => file mapping
67our %AUDIO_CHUNKS; # audio files
68
58our $ALT_ENTER_MESSAGE; 69our $ALT_ENTER_MESSAGE;
59our $STATUS_LINE; 70our $STATUS_LINE;
60our $DEBUG_STATUS; 71our $DEBUG_STATUS;
61 72
62sub status { 73sub status {
63 $STATUS_LINE->set_text ($_[0]); 74 $STATUS_LINE->set_text ($_[0]);
64 my ($w, $h) = $STATUS_LINE->size_request;
65 $STATUS_LINE->size_allocate (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $h, $w, $h); 75 $STATUS_LINE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $STATUS_LINE->{h});
66} 76}
67 77
68sub debug { 78sub debug {
69 $DEBUG_STATUS->set_text ($_[0]); 79 $DEBUG_STATUS->set_text ($_[0]);
70 my ($w, $h) = $DEBUG_STATUS->size_request; 80 $DEBUG_STATUS->move ($WIDTH - $DEBUG_STATUS->{w}, 0, $DEBUG_STATUS->{w}, $DEBUG_STATUS->{h});
71 $DEBUG_STATUS->size_allocate ($WIDTH - $w, 0, $w, $h);
72} 81}
73 82
74sub start_game { 83sub start_game {
75 status "logging in..."; 84 status "logging in...";
76 85
101} 110}
102 111
103sub client_setup { 112sub client_setup {
104 my $dialog = new CFClient::UI::FancyFrame 113 my $dialog = new CFClient::UI::FancyFrame
105 child => (my $vbox = new CFClient::UI::VBox); 114 child => (my $vbox = new CFClient::UI::VBox);
106 $vbox->add (new CFClient::UI::Label align => 0, text => "Client Setup"); 115 $vbox->add (new CFClient::UI::Label valign => 0, align => 0, text => "Client Setup");
107 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); 116 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]);
108 117
109 $table->add (0, 0, new CFClient::UI::Label align => 1, text => "Video Mode"); 118 $table->add (0, 0, new CFClient::UI::Label valign => 0, align => 1, text => "Video Mode");
110 $table->add (1, 0, my $hbox = new CFClient::UI::HBox); 119 $table->add (1, 0, my $hbox = new CFClient::UI::HBox);
111 120
112 $hbox->add (my $mode_slider = new CFClient::UI::Slider expand => 1, req_w => 100, range => [$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1]); 121 $hbox->add (my $mode_slider = new CFClient::UI::Slider expand => 1, req_w => 100, range => [$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1]);
113 $hbox->add (my $mode_label = new CFClient::UI::Label height => $FONTSIZE * 0.8); 122 $hbox->add (my $mode_label = new CFClient::UI::Label valign => 0, height => 0.8);
114 123
115 $mode_slider->connect (changed => sub { 124 $mode_slider->connect (changed => sub {
116 my ($self, $value) = @_; 125 my ($self, $value) = @_;
117 126
118 $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value; 127 $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value;
119 $mode_label->set_text (sprintf "%dx%d", @{$SDL_MODES[$value]}); 128 $mode_label->set_text (sprintf "%dx%d", @{$SDL_MODES[$value]});
120 }); 129 });
121 $mode_slider->emit (changed => $mode_slider->{range}[0]); 130 $mode_slider->emit (changed => $mode_slider->{range}[0]);
122 131
123 $table->add (0, 1, new CFClient::UI::Label align => 1, text => "Fullscreen"); 132 $table->add (0, 1, new CFClient::UI::Label valign => 0, align => 1, text => "Fullscreen");
124 $table->add (1, 1, new CFClient::UI::CheckBox state => $CFG->{fullscreen}, connect_changed => sub { 133 $table->add (1, 1, new CFClient::UI::CheckBox state => $CFG->{fullscreen}, connect_changed => sub {
125 my ($self, $value) = @_; 134 my ($self, $value) = @_;
126 $CFG->{fullscreen} = $value; 135 $CFG->{fullscreen} = $value;
127 }); 136 });
128 137
129 $table->add (0, 2, new CFClient::UI::Label align => 1, text => "Fast & Ugly"); 138 $table->add (0, 2, new CFClient::UI::Label valign => 0, align => 1, text => "Fast & Ugly");
130 $table->add (1, 2, new CFClient::UI::CheckBox state => $CFG->{fast}, connect_changed => sub { 139 $table->add (1, 2, new CFClient::UI::CheckBox state => $CFG->{fast}, connect_changed => sub {
131 my ($self, $value) = @_; 140 my ($self, $value) = @_;
132 $CFG->{fast} = $value; 141 $CFG->{fast} = $value;
133 }); 142 });
134 143
135 $table->add (0, 3, new CFClient::UI::Label align => 1, text => "Fog of War"); 144 $table->add (0, 3, new CFClient::UI::Label valign => 0, align => 1, text => "Fog of War");
136 $table->add (1, 3, new CFClient::UI::CheckBox state => $CFG->{fow_enable}, connect_changed => sub { 145 $table->add (1, 3, new CFClient::UI::CheckBox state => $CFG->{fow_enable}, connect_changed => sub {
137 my ($self, $value) = @_; 146 my ($self, $value) = @_;
138 $CFG->{fow_enable} = $value; 147 $CFG->{fow_enable} = $value;
139 }); 148 });
140 149
141 $table->add (0, 4, new CFClient::UI::Label align => 1, text => "FoW Intensity"); 150 $table->add (0, 4, new CFClient::UI::Label valign => 0, align => 1, text => "FoW Intensity");
142 $table->add (1, 4, new CFClient::UI::Slider range => [$CFG->{fow_intensity}, 0, 1 + 0.001, 0.001], connect_changed => sub { 151 $table->add (1, 4, new CFClient::UI::Slider range => [$CFG->{fow_intensity}, 0, 1 + 0.001, 0.001], connect_changed => sub {
143 my ($self, $value) = @_; 152 my ($self, $value) = @_;
144 $CFG->{fow_intensity} = $value; 153 $CFG->{fow_intensity} = $value;
145 }); 154 });
146 155
147 $table->add (0, 5, new CFClient::UI::Label align => 1, text => "FoW Smooth"); 156 $table->add (0, 5, new CFClient::UI::Label valign => 0, align => 1, text => "FoW Smooth");
148 $table->add (1, 5, new CFClient::UI::CheckBox state => $CFG->{fow_smooth}, connect_changed => sub { 157 $table->add (1, 5, new CFClient::UI::CheckBox state => $CFG->{fow_smooth}, connect_changed => sub {
149 my ($self, $value) = @_; 158 my ($self, $value) = @_;
150 $CFG->{fow_smooth} = $value; 159 $CFG->{fow_smooth} = $value;
160 status "Fog of War smoothing requires OpenGL 1.2 or higher" if $CFClient::GL_VERSION < 1.2;
151 }); 161 });
152 162
153 $table->add (0, 6, new CFClient::UI::Label align => 1, text => "Log Fontsize"); 163 $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "Log Fontsize");
164 $table->add (1, 6, new CFClient::UI::Slider range => [$CFG->{gui_fontsize}, 0.5, 1.5, 0.1], connect_changed => sub {
165 $CFG->{gui_fontsize} = 0.1 * int $_[0] * 10;
166# $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize};
167 });
168
169 $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Log Fontsize");
154 $table->add (1, 6, new CFClient::UI::Slider range => [$CFG->{log_fontsize}, 8, 30, 1], connect_changed => sub { 170 $table->add (1, 7, new CFClient::UI::Slider range => [$CFG->{log_fontsize}, 0.7, 1.5, 0.1], connect_changed => sub {
155 my ($self, $value) = @_;
156 $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = int $value); 171 $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = 0.1 * int $_[0] * 10);
157 }); 172 });
158 173
159 $table->add (1, 7, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { 174 $table->add (1, 8, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub {
160 destroy_screen (); 175 video_shutdown ();
161 init_screen (); 176 video_init ();
177 });
178
179 $table->add (0, 9, new CFClient::UI::Label valign => 0, align => 1, text => "Audio Enable");
180 $table->add (1, 9, new CFClient::UI::CheckBox state => $CFG->{audio_enable}, connect_changed => sub {
181 $CFG->{audio_enable} = $_[1];
182 });
183# $table->add (0, 9, new CFClient::UI::Label valign => 0, align => 1, text => "Effects Volume");
184# $table->add (1, 8, new CFClient::UI::Slider range => [$CFG->{effects_volume}, 0, 128, 1], connect_changed => sub {
185# $CFG->{effects_volume} = $_[1];
186# });
187 $table->add (0, 10, new CFClient::UI::Label valign => 0, align => 1, text => "Bg. Music");
188 $table->add (1, 10, my $hbox = new CFClient::UI::HBox);
189 $hbox->add (new CFClient::UI::CheckBox expand => 1, state => $CFG->{bgm_enable}, connect_changed => sub {
190 $CFG->{bgm_enable} = $_[1];
191 });
192 $hbox->add (new CFClient::UI::Slider expand => 1, range => [$CFG->{bgm_volume}, 0, 128, 1], connect_changed => sub {
193 $CFG->{bgm_volume} = $_[1];
194 $SDL_MIXER->music_volume ($_[1]);
195 });
196
197 $table->add (1, 11, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub {
198 audio_shutdown ();
199 audio_init ();
162 }); 200 });
163 201
164 $dialog 202 $dialog
165} 203}
166 204
230 $HOST->set_text ($CFG->{host} = $host); 268 $HOST->set_text ($CFG->{host} = $host);
231 }), 269 }),
232 (new CFClient::UI::Empty expand => 1), 270 (new CFClient::UI::Empty expand => 1),
233 ]); 271 ]);
234 272
235 $table->add ($_ + 1, $y, new CFClient::UI::Label align => $align[$_], text => $m->[$_], fontsize => $FONTSIZE * 0.8) 273 $table->add ($_ + 1, $y, new CFClient::UI::Label align => $align[$_], text => $m->[$_], fontsize => 0.8)
236 for 0 .. $#$m; 274 for 0 .. $#$m;
237 } 275 }
238 } 276 }
239 }); 277 });
240} 278}
300 338
301sub message_window { 339sub message_window {
302 my $window = new CFClient::UI::FancyFrame 340 my $window = new CFClient::UI::FancyFrame
303 border_bg => [1, 1, 1, 0.5], 341 border_bg => [1, 1, 1, 0.5],
304 bg => [0.3, 0.3, 0.3, 0.8], 342 bg => [0.3, 0.3, 0.3, 0.8],
305 user_w => $::WIDTH/4, 343 user_w => int $::WIDTH / 3,
306 user_h => $::HEIGHT, 344 user_h => int $::HEIGHT / 5,
307 child => (my $vbox = new CFClient::UI::VBox); 345 child => (my $vbox = new CFClient::UI::VBox);
308 346
309 $vbox->add ($LOGVIEW = new CFClient::UI::TextView 347 $vbox->add ($LOGVIEW = new CFClient::UI::TextView
310 expand => 1, 348 expand => 1,
311 fontsize => $::CFG->{log_fontsize}, 349 fontsize => $::CFG->{log_fontsize},
312 ); 350 );
313 351
314 $vbox->add (my $input = new CFClient::UI::LineEntry 352 $vbox->add (my $input = new CFClient::UI::Entry
315 connect_focus_in => sub { 353 connect_focus_in => sub {
316 my ($input, $prev_focus) = @_; 354 my ($input, $prev_focus) = @_;
317 355
318 delete $input->{refocus_map}; 356 delete $input->{refocus_map};
319 357
325 connect_activate => sub { 363 connect_activate => sub {
326 my ($input, $text) = @_; 364 my ($input, $text) = @_;
327 $input->set_text (''); 365 $input->set_text ('');
328 366
329 if ($text =~ /^\/(.*)/) { 367 if ($text =~ /^\/(.*)/) {
330 $::CONN->user_send ("command $1"); 368 $::CONN->user_send ($1);
331 } else { 369 } else {
332 my $say_cmd = $::CFG->{say_command} || 'say'; 370 my $say_cmd = $::CFG->{say_command} || 'say';
333 $::CONN->user_send ("command $say_cmd $text"); 371 $::CONN->user_send ("$say_cmd $text");
334 } 372 }
335 if ($input->{refocus_map}) { 373 if ($input->{refocus_map}) {
336 delete $input->{refocus_map}; 374 delete $input->{refocus_map};
337 $MAPWIDGET->focus_in 375 $MAPWIDGET->focus_in
338 } 376 }
354 #SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE 392 #SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE
355 SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO 393 SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO
356 and die "SDL::Init failed!\n"; 394 and die "SDL::Init failed!\n";
357} 395}
358 396
359sub init_screen { 397sub video_init {
360 sdl_init; 398 sdl_init;
361 399
362 ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; 400 ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] };
363 $FULLSCREEN = $CFG->{fullscreen}; 401 $FULLSCREEN = $CFG->{fullscreen};
364 $FAST = $CFG->{fast}; 402 $FAST = $CFG->{fast};
391 429
392 $LAST_REFRESH = time - 0.01; 430 $LAST_REFRESH = time - 0.01;
393 431
394 CFClient::gl_init; 432 CFClient::gl_init;
395 433
396 $FONTSIZE = int $HEIGHT / 40; 434 $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize};
397 435
398 ############################################################################# 436 #############################################################################
399 437
400 $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100; 438 $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100;
401 $CFClient::UI::ROOT->add ($DEBUG_STATUS); 439 $DEBUG_STATUS->show;
402 440
403 $STATUS_LINE = new CFClient::UI::Label 441 $STATUS_LINE = new CFClient::UI::Label
404 padding => 0, 442 padding => 0,
405 y => $HEIGHT * 44 / 45 - $FONTSIZE; 443 y => $HEIGHT - $FONTSIZE * 1.8;
406 $CFClient::UI::ROOT->add ($STATUS_LINE); 444 $STATUS_LINE->show;
407 445
408 $ALT_ENTER_MESSAGE = new CFClient::UI::Label 446 $ALT_ENTER_MESSAGE = new CFClient::UI::Label
409 padding => 0, 447 padding => 0,
410 y => $HEIGHT * 44 / 45, 448 fontsize => 0.8,
411 height => $HEIGHT / 45,
412 text => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; 449 markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode";
413 $CFClient::UI::ROOT->add ($ALT_ENTER_MESSAGE); 450 $ALT_ENTER_MESSAGE->show;
451 $ALT_ENTER_MESSAGE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h});
414 452
415 $CFClient::UI::ROOT->add ($MAPWIDGET = new CFClient::UI::MapWidget); 453 $CFClient::UI::ROOT->add ($MAPWIDGET = new CFClient::UI::MapWidget);
416 $MAPWIDGET->focus_in; 454 $MAPWIDGET->focus_in;
417 $MAPWIDGET->connect (activate_console => sub { 455 $MAPWIDGET->connect (activate_console => sub {
418 my ($mapwidget, $preset) = @_; 456 my ($mapwidget, $preset) = @_;
437 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; 475 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc";
438 status "Configuration Saved"; 476 status "Configuration Saved";
439 }); 477 });
440 478
441 $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup 479 $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup
442}
443 480
444sub destroy_screen { 481 my $tgw = new CFClient::UI::FancyFrame (x => $WIDTH - 300, y => 0);
482 $tgw->add (my $hbox = new CFClient::UI::HBox ());
483
484 $hbox->add (my $hg = new CFClient::UI::VGauge (gauge => 'hp'));
485 $hbox->add (my $mg = new CFClient::UI::VGauge (gauge => 'mana'));
486 $hbox->add (my $gg = new CFClient::UI::VGauge (gauge => 'grace'));
487 $hbox->add (my $fg = new CFClient::UI::VGauge (gauge => 'food'));
488
489 $GAUGES = { food => $fg, mana => $mg, hp => $hg, grace => $gg };
490 $CFClient::UI::ROOT->add ($tgw);
491}
492
493sub video_shutdown {
445 $CFClient::UI::ROOT->{children} = []; 494 $CFClient::UI::ROOT->{children} = [];
446 undef $SDL_ACTIVE; 495 undef $SDL_ACTIVE;
447 undef $SDL_EV; 496 undef $SDL_EV;
448 SDL::Quit; 497}
498
499my $bgmusic;#TODO#hack#d#
500
501sub audio_init {
502 if ($CFG->{audio_enable}) {
503 if (open my $fh, "<:utf8", CFClient::find_rcfile "sounds/config") {
504 $SDL_MIXER = new SDL::Mixer;
505 $SDL_MIXER->allocate_channels (8);
506
507 # TODO: hack, do play loop and mood music
508 if ($CFG->{bgm_enable}) {
509 $bgmusic = new SDL::Music CFClient::find_rcfile "music/game3.ogg";
510 $SDL_MIXER->play_music ($bgmusic, -1);
511 $SDL_MIXER->music_volume ($CFG->{bgm_volume});
512 }
513
514 while (<$fh>) {
515 next if /^\s*#/;
516 next if /^\s*$/;
517
518 my ($file, $volume, $event) = split /\s+/, $_, 3;
519
520 push @SOUNDS, "$volume,$file";
521
522 $AUDIO_CHUNKS{"$volume,$file"} ||= do {
523 my $chunk = new SDL::Sound CFClient::find_rcfile "sounds/$file";
524 $chunk->volume ($volume * 128 / 100);
525 $chunk
526 };
527 }
528 } else {
529 status "unable to open sound config: $!";
530 }
531 }
532}
533
534sub audio_shutdown {
535 undef $SDL_MIXER;
536 @SOUNDS = ();
537 %AUDIO_CHUNKS = ();
449} 538}
450 539
451my %animate_object; 540my %animate_object;
452my $animate_timer; 541my $animate_timer;
453 542
502 delete $animate_object{$widget}; 591 delete $animate_object{$widget};
503} 592}
504 593
505@conn::ISA = Crossfire::Protocol::; 594@conn::ISA = Crossfire::Protocol::;
506 595
596sub conn::stats_update {
597 my ($self, $stats) = @_;
598
599 # i love text protocols!!!
600 # FIXME: the stats are somehow weird
601 my $hp = $stats->{1};
602 my $hp_m = $stats->{2};
603 my $sp = $stats->{3};
604 my $sp_m = $stats->{4};
605 my $fo = $stats->{18};
606 my $fo_m = 1000;
607 my $gr = $stats->{23};
608 my $gr_m = $stats->{24};
609
610 #d# warn "DATA $hp $hp_m $sp $sp_m $fo $fo_m $gr $gr_m\n";
611 $GAUGES->{hp}->set_value ($hp, $hp_m);
612 $GAUGES->{mana}->set_value ($sp, $sp_m);
613 $GAUGES->{food}->set_value ($fo, $fo_m);
614 $GAUGES->{grace}->set_value ($gr, $gr_m);
615}
616
507sub conn::user_send { 617sub conn::user_send {
508 my ($self, $command) = @_; 618 my ($self, $command) = @_;
509 619
510 $self->send ($command); 620 $self->send_command ($command);
511 status $command; 621 status $command;
512} 622}
513 623
514sub conn::map_scroll { 624sub conn::map_scroll {
515 my ($self, $dx, $dy) = @_; 625 my ($self, $dx, $dy) = @_;
579 my $neigh = $self->{neigh}{$hash} ||= []; 689 my $neigh = $self->{neigh}{$hash} ||= [];
580 690
581 $self->send_mapinfo ("spatial $path$tile", sub { 691 $self->send_mapinfo ("spatial $path$tile", sub {
582 my ($mode, $flags, $x, $y, $w, $h, $hash) = @_; 692 my ($mode, $flags, $x, $y, $w, $h, $hash) = @_;
583 693
584 warn "map<$path>_$tile=<$mode,$x,$y,$w,$h,$hash>\n";#d# 694 #warn "map<$path>_$tile=<$mode,$x,$y,$w,$h,$hash>\n";#d#
585 return if $mode ne "spatial"; 695 return if $mode ne "spatial";
586 696
587 $x += $MAP->ox; 697 $x += $MAP->ox;
588 $y += $MAP->oy; 698 $y += $MAP->oy;
589 699
590 $self->load_map ($hash, $x, $y); 700 $self->load_map ($hash, $x, $y)
701 unless $self->{neigh}{$hash}[5]++;#d#
591 702
592 $neigh->[$tile] = [$x, $y, $w, $h]; 703 $neigh->[$tile] = [$x, $y, $w, $h];
593 704
594 $self->flood_fill ("$path$tile", $hash, $flags, $x0, $y0, $x1, $y1) 705 $self->flood_fill ("$path$tile", $hash, $flags, $x0, $y0, $x1, $y1)
595 if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1; 706 if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1;
601 my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_; 712 my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_;
602 713
603 $self->flush_map; 714 $self->flush_map;
604 715
605 my ($ox, $oy) = ($::MAP->ox, $::MAP->oy); 716 my ($ox, $oy) = ($::MAP->ox, $::MAP->oy);
606
607 warn "$ox $oy map_info<$flags, $x, $y, $w, $h, $hash>\n";#d#
608 717
609 my $mapmapw = 250; 718 my $mapmapw = 250;
610 my $mapmaph = 250; 719 my $mapmaph = 250;
611 720
612 $self->flood_fill ("", $hash, $flags, 721 $self->flood_fill ("", $hash, $flags,
674 $MAP->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}}); 783 $MAP->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}});
675 $MAPWIDGET->update; 784 $MAPWIDGET->update;
676 785
677 $tex 786 $tex
678 }; 787 };
788}
789
790sub conn::sound_play {
791 my ($self, $x, $y, $soundnum, $type) = @_;
792
793 $SDL_MIXER
794 or return;
795
796 my $chunk = $AUDIO_CHUNKS{$SOUNDS[$soundnum]}
797 or return;
798
799 $SDL_MIXER->play_channel (-1, $chunk);
800 warn "sound $x,$y,$soundnum,$type\n";#d#
679} 801}
680 802
681sub conn::query { 803sub conn::query {
682 my ($self, $flags, $prompt) = @_; 804 my ($self, $flags, $prompt) = @_;
683 805
717 refresh; 839 refresh;
718 }, 840 },
719 SDL_KEYDOWN() => sub { 841 SDL_KEYDOWN() => sub {
720 if ($SDL_EV->key_mod & KMOD_ALT && $SDL_EV->key_sym == SDLK_RETURN) { 842 if ($SDL_EV->key_mod & KMOD_ALT && $SDL_EV->key_sym == SDLK_RETURN) {
721 # alt-enter 843 # alt-enter
722 destroy_screen; 844 video_shutdown;
723 $CFG->{fullscreen} = !$CFG->{fullscreen}; 845 $CFG->{fullscreen} = !$CFG->{fullscreen};
724 init_screen; 846 video_init;
725 } else { 847 } else {
726 CFClient::UI::feed_sdl_key_down_event ($SDL_EV); 848 CFClient::UI::feed_sdl_key_down_event ($SDL_EV);
727 } 849 }
728 }, 850 },
729 SDL_KEYUP() => sub { 851 SDL_KEYUP() => sub {
743 }, 865 },
744); 866);
745 867
746############################################################################# 868#############################################################################
747 869
870$SIG{INT} = $SIG{TERM} = sub { exit };
871
748$TILECACHE = CFClient::db_table "tilecache"; 872$TILECACHE = CFClient::db_table "tilecache";
749$FACEMAP = CFClient::db_table "facemap"; 873$FACEMAP = CFClient::db_table "facemap";
750 874
751CFClient::read_cfg "$Crossfire::VARDIR/pclientrc"; 875CFClient::read_cfg "$Crossfire::VARDIR/pclientrc";
752 876
757 fullscreen => 0, 881 fullscreen => 0,
758 fast => 0, 882 fast => 0,
759 fow_enable => 1, 883 fow_enable => 1,
760 fow_intensity => 0.45, 884 fow_intensity => 0.45,
761 fow_smooth => 0, 885 fow_smooth => 0,
886 gui_fontsize => 1,
762 log_fontsize => 14, 887 log_fontsize => 14,
763 mapsize => 100, 888 mapsize => 100,
764 host => "crossfire.schmorp.de", 889 host => "crossfire.schmorp.de",
765 say_command => 'say', 890 say_command => 'say',
891 audio_enable => 1,
892 bgm_enable => 1,
893 bgm_volume => 64,
766); 894);
767 895
768while (my ($k, $v) = each %DEF_CFG) { 896while (my ($k, $v) = each %DEF_CFG) {
769 $CFG->{$k} = $v unless exists $CFG->{$k}; 897 $CFG->{$k} = $v unless exists $CFG->{$k};
770} 898}
778 906
779@SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; 907@SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)";
780 908
781$CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES; 909$CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES;
782 910
783init_screen;
784
785{ 911{
786 my @fonts = map CFClient::find_rcfile $_, qw(uifont.ttf uifontb.ttf uifonti.ttf uifontbi.ttf); 912 my @fonts = map CFClient::find_rcfile $_, qw(uifont.ttf uifontb.ttf uifonti.ttf uifontbi.ttf);
787 913
788 CFClient::add_font $_ for @fonts; 914 CFClient::add_font $_ for @fonts;
789 CFClient::set_font $fonts[0]; 915 CFClient::set_font $fonts[0];
790} 916}
791 917
918video_init;
919audio_init;
920
792Event::loop; 921Event::loop;
793 922
923END { SDL::Quit }
794 924
925

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines