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.126 by root, Mon Apr 17 20:59:20 2006 UTC vs.
Revision 1.141 by root, Wed Apr 19 06:21:07 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
18use Compress::LZF; 23use Compress::LZF;
19 24
20use CFClient; 25use CFClient;
21use CFClient::UI; 26use CFClient::UI;
27use CFClient::MapWidget;
22 28
23our $VERSION = '0.1'; 29our $VERSION = '0.1';
24 30
25my $MAX_FPS = 60; 31my $MAX_FPS = 60;
26my $MIN_FPS = 5; # unused as of yet 32my $MIN_FPS = 5; # unused as of yet
55 61
56our $SDL_ACTIVE; 62our $SDL_ACTIVE;
57our $SDL_EV; 63our $SDL_EV;
58our %SDL_CB; 64our %SDL_CB;
59 65
66our $SDL_MIXER;
67our @SOUNDS; # event => file mapping
68our %AUDIO_CHUNKS; # audio files
69
60our $ALT_ENTER_MESSAGE; 70our $ALT_ENTER_MESSAGE;
61our $STATUS_LINE; 71our $STATUS_LINE;
62our $DEBUG_STATUS; 72our $DEBUG_STATUS;
63 73
64sub status { 74sub status {
65 $STATUS_LINE->set_text ($_[0]); 75 $STATUS_LINE->set_text ($_[0]);
66 my ($w, $h) = $STATUS_LINE->size_request;
67 $STATUS_LINE->size_allocate (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $h, $w, $h); 76 $STATUS_LINE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $STATUS_LINE->{h});
68} 77}
69 78
70sub debug { 79sub debug {
71 $DEBUG_STATUS->set_text ($_[0]); 80 $DEBUG_STATUS->set_text ($_[0]);
72 my ($w, $h) = $DEBUG_STATUS->size_request; 81 $DEBUG_STATUS->move ($WIDTH - $DEBUG_STATUS->{w}, 0, $DEBUG_STATUS->{w}, $DEBUG_STATUS->{h});
73 $DEBUG_STATUS->size_allocate ($WIDTH - $w, 0, $w, $h);
74} 82}
75 83
76sub start_game { 84sub start_game {
77 status "logging in..."; 85 status "logging in...";
78 86
103} 111}
104 112
105sub client_setup { 113sub client_setup {
106 my $dialog = new CFClient::UI::FancyFrame 114 my $dialog = new CFClient::UI::FancyFrame
107 child => (my $vbox = new CFClient::UI::VBox); 115 child => (my $vbox = new CFClient::UI::VBox);
108 $vbox->add (new CFClient::UI::Label align => 0, text => "Client Setup"); 116 $vbox->add (new CFClient::UI::Label valign => 0, align => 0, text => "Client Setup");
109 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); 117 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]);
110 118
111 $table->add (0, 0, new CFClient::UI::Label align => 1, text => "Video Mode"); 119 $table->add (0, 0, new CFClient::UI::Label valign => 0, align => 1, text => "Video Mode");
112 $table->add (1, 0, my $hbox = new CFClient::UI::HBox); 120 $table->add (1, 0, my $hbox = new CFClient::UI::HBox);
113 121
114 $hbox->add (my $mode_slider = new CFClient::UI::Slider expand => 1, req_w => 100, range => [$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1]); 122 $hbox->add (my $mode_slider = new CFClient::UI::Slider expand => 1, req_w => 100, range => [$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1]);
115 $hbox->add (my $mode_label = new CFClient::UI::Label height => $FONTSIZE * 0.8); 123 $hbox->add (my $mode_label = new CFClient::UI::Label valign => 0, height => 0.8);
116 124
117 $mode_slider->connect (changed => sub { 125 $mode_slider->connect (changed => sub {
118 my ($self, $value) = @_; 126 my ($self, $value) = @_;
119 127
120 $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value; 128 $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value;
121 $mode_label->set_text (sprintf "%dx%d", @{$SDL_MODES[$value]}); 129 $mode_label->set_text (sprintf "%dx%d", @{$SDL_MODES[$value]});
122 }); 130 });
123 $mode_slider->emit (changed => $mode_slider->{range}[0]); 131 $mode_slider->emit (changed => $mode_slider->{range}[0]);
124 132
125 $table->add (0, 1, new CFClient::UI::Label align => 1, text => "Fullscreen"); 133 $table->add (0, 1, new CFClient::UI::Label valign => 0, align => 1, text => "Fullscreen");
126 $table->add (1, 1, new CFClient::UI::CheckBox state => $CFG->{fullscreen}, connect_changed => sub { 134 $table->add (1, 1, new CFClient::UI::CheckBox state => $CFG->{fullscreen}, connect_changed => sub {
127 my ($self, $value) = @_; 135 my ($self, $value) = @_;
128 $CFG->{fullscreen} = $value; 136 $CFG->{fullscreen} = $value;
129 }); 137 });
130 138
131 $table->add (0, 2, new CFClient::UI::Label align => 1, text => "Fast & Ugly"); 139 $table->add (0, 2, new CFClient::UI::Label valign => 0, align => 1, text => "Fast & Ugly");
132 $table->add (1, 2, new CFClient::UI::CheckBox state => $CFG->{fast}, connect_changed => sub { 140 $table->add (1, 2, new CFClient::UI::CheckBox state => $CFG->{fast}, connect_changed => sub {
133 my ($self, $value) = @_; 141 my ($self, $value) = @_;
134 $CFG->{fast} = $value; 142 $CFG->{fast} = $value;
135 }); 143 });
136 144
137 $table->add (0, 3, new CFClient::UI::Label align => 1, text => "Fog of War"); 145 $table->add (0, 3, new CFClient::UI::Label valign => 0, align => 1, text => "Fog of War");
138 $table->add (1, 3, new CFClient::UI::CheckBox state => $CFG->{fow_enable}, connect_changed => sub { 146 $table->add (1, 3, new CFClient::UI::CheckBox state => $CFG->{fow_enable}, connect_changed => sub {
139 my ($self, $value) = @_; 147 my ($self, $value) = @_;
140 $CFG->{fow_enable} = $value; 148 $CFG->{fow_enable} = $value;
141 }); 149 });
142 150
143 $table->add (0, 4, new CFClient::UI::Label align => 1, text => "FoW Intensity"); 151 $table->add (0, 4, new CFClient::UI::Label valign => 0, align => 1, text => "FoW Intensity");
144 $table->add (1, 4, new CFClient::UI::Slider range => [$CFG->{fow_intensity}, 0, 1 + 0.001, 0.001], connect_changed => sub { 152 $table->add (1, 4, new CFClient::UI::Slider range => [$CFG->{fow_intensity}, 0, 1 + 0.001, 0.001], connect_changed => sub {
145 my ($self, $value) = @_; 153 my ($self, $value) = @_;
146 $CFG->{fow_intensity} = $value; 154 $CFG->{fow_intensity} = $value;
147 }); 155 });
148 156
149 $table->add (0, 5, new CFClient::UI::Label align => 1, text => "FoW Smooth"); 157 $table->add (0, 5, new CFClient::UI::Label valign => 0, align => 1, text => "FoW Smooth");
150 $table->add (1, 5, new CFClient::UI::CheckBox state => $CFG->{fow_smooth}, connect_changed => sub { 158 $table->add (1, 5, new CFClient::UI::CheckBox state => $CFG->{fow_smooth}, connect_changed => sub {
151 my ($self, $value) = @_; 159 my ($self, $value) = @_;
152 $CFG->{fow_smooth} = $value; 160 $CFG->{fow_smooth} = $value;
161 status "Fog of War smoothing requires OpenGL 1.2 or higher" if $CFClient::GL_VERSION < 1.2;
153 }); 162 });
154 163
155 $table->add (0, 6, new CFClient::UI::Label align => 1, text => "Log Fontsize"); 164 $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "GUI Fontsize");
165 $table->add (1, 6, new CFClient::UI::Slider range => [$CFG->{gui_fontsize}, 0.7, 1.7, 0.1], connect_changed => sub {
166 $CFG->{gui_fontsize} = 0.1 * int $_[1] * 10;
167# $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize};
168 });
169
170 $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Server Log Fontsize");
156 $table->add (1, 6, new CFClient::UI::Slider range => [$CFG->{log_fontsize}, 8, 30, 1], connect_changed => sub { 171 $table->add (1, 7, new CFClient::UI::Slider range => [$CFG->{log_fontsize}, 0.7, 1.7, 0.1], connect_changed => sub {
157 my ($self, $value) = @_;
158 $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = int $value); 172 $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = 0.1 * int $_[1] * 10);
159 }); 173 });
160 174
161 $table->add (1, 7, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { 175 $table->add (1, 8, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub {
162 destroy_screen (); 176 video_shutdown ();
163 init_screen (); 177 video_init ();
178 });
179
180 $table->add (0, 9, new CFClient::UI::Label valign => 0, align => 1, text => "Audio Enable");
181 $table->add (1, 9, new CFClient::UI::CheckBox state => $CFG->{audio_enable}, connect_changed => sub {
182 $CFG->{audio_enable} = $_[1];
183 });
184# $table->add (0, 9, new CFClient::UI::Label valign => 0, align => 1, text => "Effects Volume");
185# $table->add (1, 8, new CFClient::UI::Slider range => [$CFG->{effects_volume}, 0, 128, 1], connect_changed => sub {
186# $CFG->{effects_volume} = $_[1];
187# });
188 $table->add (0, 10, new CFClient::UI::Label valign => 0, align => 1, text => "Background Music");
189 $table->add (1, 10, my $hbox = new CFClient::UI::HBox);
190 $hbox->add (new CFClient::UI::CheckBox expand => 1, state => $CFG->{bgm_enable}, connect_changed => sub {
191 $CFG->{bgm_enable} = $_[1];
192 });
193 $hbox->add (new CFClient::UI::Slider expand => 1, range => [$CFG->{bgm_volume}, 0, 128, 1], connect_changed => sub {
194 $CFG->{bgm_volume} = $_[1];
195 $SDL_MIXER->music_volume ($_[1]);
196 });
197
198 $table->add (1, 11, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub {
199 audio_shutdown ();
200 audio_init ();
164 }); 201 });
165 202
166 $dialog 203 $dialog
167} 204}
168 205
232 $HOST->set_text ($CFG->{host} = $host); 269 $HOST->set_text ($CFG->{host} = $host);
233 }), 270 }),
234 (new CFClient::UI::Empty expand => 1), 271 (new CFClient::UI::Empty expand => 1),
235 ]); 272 ]);
236 273
237 $table->add ($_ + 1, $y, new CFClient::UI::Label align => $align[$_], text => $m->[$_], fontsize => $FONTSIZE * 0.8) 274 $table->add ($_ + 1, $y, new CFClient::UI::Label align => $align[$_], text => $m->[$_], fontsize => 0.8)
238 for 0 .. $#$m; 275 for 0 .. $#$m;
239 } 276 }
240 } 277 }
241 }); 278 });
242} 279}
243 280
244sub server_setup { 281sub server_setup {
245 my $dialog = new CFClient::UI::FancyFrame 282 my $dialog = new CFClient::UI::FancyFrame
246 child => (my $vbox = new CFClient::UI::VBox); 283 child => (my $vbox = new CFClient::UI::VBox);
247 284
248 $vbox->add (new CFClient::UI::Label align => 0, text => "Server Setup"); 285 $vbox->add (new CFClient::UI::Label valign => 0, align => 0, text => "Server Setup");
249 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); 286 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]);
250 $table->add (0, 2, new CFClient::UI::Label align => 1, text => "Host:Port"); 287 $table->add (0, 2, new CFClient::UI::Label valign => 0, align => 1, text => "Host:Port");
251 288
252 { 289 {
253 $table->add (1, 2, my $vbox = new CFClient::UI::VBox); 290 $table->add (1, 2, my $vbox = new CFClient::UI::VBox);
254 291
255 $vbox->add (my $HOST = new CFClient::UI::Entry text => $CFG->{host}, connect_changed => sub { 292 $vbox->add (my $HOST = new CFClient::UI::Entry expand => 1, text => $CFG->{host}, connect_changed => sub {
256 my ($self, $value) = @_; 293 my ($self, $value) = @_;
257 $CFG->{host} = $value; 294 $CFG->{host} = $value;
258 }); 295 });
259 296
260 $METASERVER = metaserver_dialog; 297 $METASERVER = metaserver_dialog;
261 298
262 $vbox->add (new CFClient::UI::Flopper text => "Metaserver", other => $METASERVER, connect_open => sub { 299 $vbox->add (new CFClient::UI::Flopper expand => 1, text => "Metaserver", other => $METASERVER, connect_open => sub {
263 update_metaserver $HOST; 300 update_metaserver $HOST;
264 }); 301 });
265 } 302 }
266 303
267 $table->add (0, 4, new CFClient::UI::Label align => 1, text => "Username"); 304 $table->add (0, 4, new CFClient::UI::Label valign => 0, align => 1, text => "Username");
268 $table->add (1, 4, new CFClient::UI::Entry text => $CFG->{user}, connect_changed => sub { 305 $table->add (1, 4, new CFClient::UI::Entry text => $CFG->{user}, connect_changed => sub {
269 my ($self, $value) = @_; 306 my ($self, $value) = @_;
270 $CFG->{user} = $value; 307 $CFG->{user} = $value;
271 }); 308 });
272 309
273 $table->add (0, 5, new CFClient::UI::Label align => 1, text => "Password"); 310 $table->add (0, 5, new CFClient::UI::Label valign => 0, align => 1, text => "Password");
274 $table->add (1, 5, new CFClient::UI::Entry text => $CFG->{password}, hidden => 1, connect_changed => sub { 311 $table->add (1, 5, new CFClient::UI::Entry text => $CFG->{password}, hidden => 1, connect_changed => sub {
275 my ($self, $value) = @_; 312 my ($self, $value) = @_;
276 $CFG->{password} = $value; 313 $CFG->{password} = $value;
277 }); 314 });
278 315
279 $table->add (0, 6, new CFClient::UI::Label align => 1, text => "Def. say cmd"); 316 $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "Def. say cmd");
280 $table->add (1, 6, my $saycmd = new CFClient::UI::Entry text => $CFG->{say_command}, connect_changed => sub { 317 $table->add (1, 6, my $saycmd = new CFClient::UI::Entry text => $CFG->{say_command}, connect_changed => sub {
281 my ($self, $value) = @_; 318 my ($self, $value) = @_;
282 $CFG->{say_command} = $value; 319 $CFG->{say_command} = $value;
283 }); 320 });
284 321
285 $table->add (0, 7, new CFClient::UI::Label align => 1, text => "Map Size"); 322 $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size");
286 $table->add (1, 7, new CFClient::UI::Slider 323 $table->add (1, 7, new CFClient::UI::Slider
287 req_w => 100, 324 req_w => 100,
288 range => [$CFG->{mapsize}, 10, 100 + 1, 1], 325 range => [$CFG->{mapsize}, 10, 100 + 1, 1],
289 connect_changed => sub { 326 connect_changed => sub {
290 my ($self, $value) = @_; 327 my ($self, $value) = @_;
356 #SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE 393 #SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE
357 SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO 394 SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO
358 and die "SDL::Init failed!\n"; 395 and die "SDL::Init failed!\n";
359} 396}
360 397
361sub init_screen { 398sub video_init {
362 sdl_init; 399 sdl_init;
363 400
364 ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; 401 ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] };
365 $FULLSCREEN = $CFG->{fullscreen}; 402 $FULLSCREEN = $CFG->{fullscreen};
366 $FAST = $CFG->{fast}; 403 $FAST = $CFG->{fast};
393 430
394 $LAST_REFRESH = time - 0.01; 431 $LAST_REFRESH = time - 0.01;
395 432
396 CFClient::gl_init; 433 CFClient::gl_init;
397 434
398 $FONTSIZE = int $HEIGHT / 40; 435 $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize};
399 436
400 ############################################################################# 437 #############################################################################
401 438
402 $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100; 439 $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100;
403 $CFClient::UI::ROOT->add ($DEBUG_STATUS); 440 $DEBUG_STATUS->show;
404 441
405 $STATUS_LINE = new CFClient::UI::Label 442 $STATUS_LINE = new CFClient::UI::Label
406 padding => 0, 443 padding => 0,
407 y => $HEIGHT * 44 / 45 - $FONTSIZE; 444 y => $HEIGHT - $FONTSIZE * 1.8;
408 $CFClient::UI::ROOT->add ($STATUS_LINE); 445 $STATUS_LINE->show;
409 446
410 $ALT_ENTER_MESSAGE = new CFClient::UI::Label 447 $ALT_ENTER_MESSAGE = new CFClient::UI::Label
411 padding => 0, 448 padding => 0,
412 y => $HEIGHT * 44 / 45,
413 fontsize => $HEIGHT / 45, 449 fontsize => 0.8,
414 markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; 450 markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode";
415 $CFClient::UI::ROOT->add ($ALT_ENTER_MESSAGE); 451 $ALT_ENTER_MESSAGE->show;
452 $ALT_ENTER_MESSAGE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h});
416 453
417 $CFClient::UI::ROOT->add ($MAPWIDGET = new CFClient::UI::MapWidget); 454 $CFClient::UI::ROOT->add ($MAPWIDGET = new CFClient::MapWidget);
418 $MAPWIDGET->focus_in; 455 $MAPWIDGET->focus_in;
419 $MAPWIDGET->connect (activate_console => sub { 456 $MAPWIDGET->connect (activate_console => sub {
420 my ($mapwidget, $preset) = @_; 457 my ($mapwidget, $preset) = @_;
421 458
422 if ($CONSOLE) { 459 if ($CONSOLE) {
440 status "Configuration Saved"; 477 status "Configuration Saved";
441 }); 478 });
442 479
443 $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup 480 $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup
444 481
445 my $tgw = new CFClient::UI::FancyFrame (x => $WIDTH - 150, y => 0); 482 my $tgw = new CFClient::UI::FancyFrame (x => $WIDTH - 300, y => 0);
446 $tgw->add (my $hbox = new CFClient::UI::HBox (req_w => 60, req_h => 150)); 483 $tgw->add (my $hbox = new CFClient::UI::HBox ());
447 484
448 $hbox->add (my $fg = new CFClient::UI::VGauge (w => 30, h => 150, gauge => 'food', expand => 1)); 485 $hbox->add (my $hg = new CFClient::UI::VGauge (gauge => 'hp'));
449 $hbox->add (my $mg = new CFClient::UI::VGauge (w => 30, h => 150, gauge => 'mana', expand => 1)); 486 $hbox->add (my $mg = new CFClient::UI::VGauge (gauge => 'mana'));
450 $hbox->add (my $hg = new CFClient::UI::VGauge (w => 30, h => 150, gauge => 'hp', expand => 1));
451 $hbox->add (my $gg = new CFClient::UI::VGauge (w => 30, h => 150, gauge => 'grace', expand => 1)); 487 $hbox->add (my $gg = new CFClient::UI::VGauge (gauge => 'grace'));
488 $hbox->add (my $fg = new CFClient::UI::VGauge (gauge => 'food'));
452 489
453 $GAUGES = { food => $fg, mana => $mg, hp => $hg, grace => $gg }; 490 $GAUGES = { food => $fg, mana => $mg, hp => $hg, grace => $gg };
454 $CFClient::UI::ROOT->add ($tgw); 491 $CFClient::UI::ROOT->add ($tgw);
455} 492}
456 493
457sub destroy_screen { 494sub video_shutdown {
458 $CFClient::UI::ROOT->{children} = []; 495 $CFClient::UI::ROOT->{children} = [];
459 undef $SDL_ACTIVE; 496 undef $SDL_ACTIVE;
460 undef $SDL_EV; 497 undef $SDL_EV;
461 SDL::Quit; 498}
499
500my $bgmusic;#TODO#hack#d#
501
502sub audio_init {
503 if ($CFG->{audio_enable}) {
504 if (open my $fh, "<:utf8", CFClient::find_rcfile "sounds/config") {
505 $SDL_MIXER = new SDL::Mixer;
506 $SDL_MIXER->allocate_channels (8);
507
508 # TODO: hack, do play loop and mood music
509 if ($CFG->{bgm_enable}) {
510 $bgmusic = new SDL::Music CFClient::find_rcfile "music/game3.ogg";
511 $SDL_MIXER->play_music ($bgmusic, -1);
512 $SDL_MIXER->music_volume ($CFG->{bgm_volume});
513 }
514
515 while (<$fh>) {
516 next if /^\s*#/;
517 next if /^\s*$/;
518
519 my ($file, $volume, $event) = split /\s+/, $_, 3;
520
521 push @SOUNDS, "$volume,$file";
522
523 $AUDIO_CHUNKS{"$volume,$file"} ||= do {
524 my $chunk = new SDL::Sound CFClient::find_rcfile "sounds/$file";
525 $chunk->volume ($volume * 128 / 100);
526 $chunk
527 };
528 }
529 } else {
530 status "unable to open sound config: $!";
531 }
532 }
533}
534
535sub audio_shutdown {
536 undef $SDL_MIXER;
537 @SOUNDS = ();
538 %AUDIO_CHUNKS = ();
462} 539}
463 540
464my %animate_object; 541my %animate_object;
465my $animate_timer; 542my $animate_timer;
466 543
636 my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_; 713 my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_;
637 714
638 $self->flush_map; 715 $self->flush_map;
639 716
640 my ($ox, $oy) = ($::MAP->ox, $::MAP->oy); 717 my ($ox, $oy) = ($::MAP->ox, $::MAP->oy);
641
642 warn "$ox $oy map_info<$flags, $x, $y, $w, $h, $hash>\n";#d#
643 718
644 my $mapmapw = 250; 719 my $mapmapw = 250;
645 my $mapmaph = 250; 720 my $mapmaph = 250;
646 721
647 $self->flood_fill ("", $hash, $flags, 722 $self->flood_fill ("", $hash, $flags,
709 $MAP->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}}); 784 $MAP->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}});
710 $MAPWIDGET->update; 785 $MAPWIDGET->update;
711 786
712 $tex 787 $tex
713 }; 788 };
789}
790
791sub conn::sound_play {
792 my ($self, $x, $y, $soundnum, $type) = @_;
793
794 $SDL_MIXER
795 or return;
796
797 my $chunk = $AUDIO_CHUNKS{$SOUNDS[$soundnum]}
798 or return;
799
800 $SDL_MIXER->play_channel (-1, $chunk);
801 warn "sound $x,$y,$soundnum,$type\n";#d#
714} 802}
715 803
716sub conn::query { 804sub conn::query {
717 my ($self, $flags, $prompt) = @_; 805 my ($self, $flags, $prompt) = @_;
718 806
752 refresh; 840 refresh;
753 }, 841 },
754 SDL_KEYDOWN() => sub { 842 SDL_KEYDOWN() => sub {
755 if ($SDL_EV->key_mod & KMOD_ALT && $SDL_EV->key_sym == SDLK_RETURN) { 843 if ($SDL_EV->key_mod & KMOD_ALT && $SDL_EV->key_sym == SDLK_RETURN) {
756 # alt-enter 844 # alt-enter
757 destroy_screen; 845 video_shutdown;
758 $CFG->{fullscreen} = !$CFG->{fullscreen}; 846 $CFG->{fullscreen} = !$CFG->{fullscreen};
759 init_screen; 847 video_init;
760 } else { 848 } else {
761 CFClient::UI::feed_sdl_key_down_event ($SDL_EV); 849 CFClient::UI::feed_sdl_key_down_event ($SDL_EV);
762 } 850 }
763 }, 851 },
764 SDL_KEYUP() => sub { 852 SDL_KEYUP() => sub {
778 }, 866 },
779); 867);
780 868
781############################################################################# 869#############################################################################
782 870
871$SIG{INT} = $SIG{TERM} = sub { exit };
872
783$TILECACHE = CFClient::db_table "tilecache"; 873$TILECACHE = CFClient::db_table "tilecache";
784$FACEMAP = CFClient::db_table "facemap"; 874$FACEMAP = CFClient::db_table "facemap";
785 875
786CFClient::read_cfg "$Crossfire::VARDIR/pclientrc"; 876CFClient::read_cfg "$Crossfire::VARDIR/pclientrc";
787 877
792 fullscreen => 0, 882 fullscreen => 0,
793 fast => 0, 883 fast => 0,
794 fow_enable => 1, 884 fow_enable => 1,
795 fow_intensity => 0.45, 885 fow_intensity => 0.45,
796 fow_smooth => 0, 886 fow_smooth => 0,
887 gui_fontsize => 1,
797 log_fontsize => 14, 888 log_fontsize => 14,
798 mapsize => 100, 889 mapsize => 100,
799 host => "crossfire.schmorp.de", 890 host => "crossfire.schmorp.de",
800 say_command => 'say', 891 say_command => 'say',
892 audio_enable => 1,
893 bgm_enable => 1,
894 bgm_volume => 64,
801); 895);
802 896
803while (my ($k, $v) = each %DEF_CFG) { 897while (my ($k, $v) = each %DEF_CFG) {
804 $CFG->{$k} = $v unless exists $CFG->{$k}; 898 $CFG->{$k} = $v unless exists $CFG->{$k};
805} 899}
820 914
821 CFClient::add_font $_ for @fonts; 915 CFClient::add_font $_ for @fonts;
822 CFClient::set_font $fonts[0]; 916 CFClient::set_font $fonts[0];
823} 917}
824 918
825init_screen; 919video_init;
920audio_init;
826 921
827Event::loop; 922Event::loop;
828 923
924END { SDL::Quit }
829 925
926

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines