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.136 by root, Tue Apr 18 06:34:30 2006 UTC vs.
Revision 1.146 by root, Wed Apr 19 21:17:16 2006 UTC

4use utf8; 4use utf8;
5 5
6use Time::HiRes 'time'; 6use Time::HiRes 'time';
7use Event; 7use Event;
8 8
9use SDL;
10use SDL::App;
11use SDL::Event; 9use SDL::Event;
12use SDL::Surface;
13
14use SDL::Mixer;
15use SDL::Sound;
16use SDL::Music;
17 10
18use SDL::OpenGL; 11use SDL::OpenGL;
19 12
20use Crossfire; 13use Crossfire;
21use Crossfire::Protocol; 14use Crossfire::Protocol;
22 15
23use Compress::LZF; 16use Compress::LZF;
24 17
25use CFClient; 18use CFClient;
26use CFClient::UI; 19use CFClient::UI;
20use CFClient::MapWidget;
27 21
28our $VERSION = '0.1'; 22our $VERSION = '0.1';
29 23
30my $MAX_FPS = 60; 24my $MAX_FPS = 60;
31my $MIN_FPS = 5; # unused as of yet 25my $MIN_FPS = 5; # unused as of yet
110} 104}
111 105
112sub client_setup { 106sub client_setup {
113 my $dialog = new CFClient::UI::FancyFrame 107 my $dialog = new CFClient::UI::FancyFrame
114 child => (my $vbox = new CFClient::UI::VBox); 108 child => (my $vbox = new CFClient::UI::VBox);
115 $vbox->add (new CFClient::UI::Label align => 0, text => "Client Setup"); 109 $vbox->add (new CFClient::UI::Label valign => 0, align => 0, text => "Client Setup");
116 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); 110 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]);
117 111
118 $table->add (0, 0, new CFClient::UI::Label align => 1, text => "Video Mode"); 112 $table->add (0, 0, new CFClient::UI::Label valign => 0, align => 1, text => "Video Mode");
119 $table->add (1, 0, my $hbox = new CFClient::UI::HBox); 113 $table->add (1, 0, my $hbox = new CFClient::UI::HBox);
120 114
121 $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_slider = new CFClient::UI::Slider expand => 1, req_w => 100, range => [$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1]);
122 $hbox->add (my $mode_label = new CFClient::UI::Label height => $FONTSIZE * 0.8); 116 $hbox->add (my $mode_label = new CFClient::UI::Label valign => 0, height => 0.8);
123 117
124 $mode_slider->connect (changed => sub { 118 $mode_slider->connect (changed => sub {
125 my ($self, $value) = @_; 119 my ($self, $value) = @_;
126 120
127 $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value; 121 $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value;
128 $mode_label->set_text (sprintf "%dx%d", @{$SDL_MODES[$value]}); 122 $mode_label->set_text (sprintf "%dx%d", @{$SDL_MODES[$value]});
129 }); 123 });
130 $mode_slider->emit (changed => $mode_slider->{range}[0]); 124 $mode_slider->emit (changed => $mode_slider->{range}[0]);
131 125
132 $table->add (0, 1, new CFClient::UI::Label align => 1, text => "Fullscreen"); 126 $table->add (0, 1, new CFClient::UI::Label valign => 0, align => 1, text => "Fullscreen");
133 $table->add (1, 1, new CFClient::UI::CheckBox state => $CFG->{fullscreen}, connect_changed => sub { 127 $table->add (1, 1, new CFClient::UI::CheckBox state => $CFG->{fullscreen}, connect_changed => sub {
134 my ($self, $value) = @_; 128 my ($self, $value) = @_;
135 $CFG->{fullscreen} = $value; 129 $CFG->{fullscreen} = $value;
136 }); 130 });
137 131
138 $table->add (0, 2, new CFClient::UI::Label align => 1, text => "Fast & Ugly"); 132 $table->add (0, 2, new CFClient::UI::Label valign => 0, align => 1, text => "Fast & Ugly");
139 $table->add (1, 2, new CFClient::UI::CheckBox state => $CFG->{fast}, connect_changed => sub { 133 $table->add (1, 2, new CFClient::UI::CheckBox state => $CFG->{fast}, connect_changed => sub {
140 my ($self, $value) = @_; 134 my ($self, $value) = @_;
141 $CFG->{fast} = $value; 135 $CFG->{fast} = $value;
142 }); 136 });
143 137
144 $table->add (0, 3, new CFClient::UI::Label align => 1, text => "Fog of War"); 138 $table->add (0, 3, new CFClient::UI::Label valign => 0, align => 1, text => "Fog of War");
145 $table->add (1, 3, new CFClient::UI::CheckBox state => $CFG->{fow_enable}, connect_changed => sub { 139 $table->add (1, 3, new CFClient::UI::CheckBox state => $CFG->{fow_enable}, connect_changed => sub {
146 my ($self, $value) = @_; 140 my ($self, $value) = @_;
147 $CFG->{fow_enable} = $value; 141 $CFG->{fow_enable} = $value;
148 }); 142 });
149 143
150 $table->add (0, 4, new CFClient::UI::Label align => 1, text => "FoW Intensity"); 144 $table->add (0, 4, new CFClient::UI::Label valign => 0, align => 1, text => "FoW Intensity");
151 $table->add (1, 4, new CFClient::UI::Slider range => [$CFG->{fow_intensity}, 0, 1 + 0.001, 0.001], connect_changed => sub { 145 $table->add (1, 4, new CFClient::UI::Slider range => [$CFG->{fow_intensity}, 0, 1 + 0.001, 0.001], connect_changed => sub {
152 my ($self, $value) = @_; 146 my ($self, $value) = @_;
153 $CFG->{fow_intensity} = $value; 147 $CFG->{fow_intensity} = $value;
154 }); 148 });
155 149
156 $table->add (0, 5, new CFClient::UI::Label align => 1, text => "FoW Smooth"); 150 $table->add (0, 5, new CFClient::UI::Label valign => 0, align => 1, text => "FoW Smooth");
157 $table->add (1, 5, new CFClient::UI::CheckBox state => $CFG->{fow_smooth}, connect_changed => sub { 151 $table->add (1, 5, new CFClient::UI::CheckBox state => $CFG->{fow_smooth}, connect_changed => sub {
158 my ($self, $value) = @_; 152 my ($self, $value) = @_;
159 $CFG->{fow_smooth} = $value; 153 $CFG->{fow_smooth} = $value;
160 status "Fog of War smoothing requires OpenGL 1.2 or higher" if $CFClient::GL_VERSION < 1.2; 154 status "Fog of War smoothing requires OpenGL 1.2 or higher" if $CFClient::GL_VERSION < 1.2;
161 }); 155 });
162 156
163 $table->add (0, 6, new CFClient::UI::Label align => 1, text => "Log Fontsize"); 157 $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "GUI Fontsize");
158 $table->add (1, 6, new CFClient::UI::Slider range => [$CFG->{gui_fontsize}, 0.7, 1.7, 0.1], connect_changed => sub {
159 $CFG->{gui_fontsize} = 0.1 * int $_[1] * 10;
160# $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize};
161 });
162
163 $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Server Log Fontsize");
164 $table->add (1, 6, new CFClient::UI::Slider range => [$CFG->{log_fontsize}, 8, 30, 1], connect_changed => sub { 164 $table->add (1, 7, new CFClient::UI::Slider range => [$CFG->{log_fontsize}, 0.7, 1.7, 0.1], connect_changed => sub {
165 my ($self, $value) = @_;
166 $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = int $value); 165 $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = 0.1 * int $_[1] * 10);
167 }); 166 });
168 167
169 $table->add (1, 7, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { 168 $table->add (1, 8, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub {
170 video_shutdown (); 169 video_shutdown ();
171 video_init (); 170 video_init ();
171 });
172
173 $table->add (0, 9, new CFClient::UI::Label valign => 0, align => 1, text => "Audio Enable");
174 $table->add (1, 9, new CFClient::UI::CheckBox state => $CFG->{audio_enable}, connect_changed => sub {
175 $CFG->{audio_enable} = $_[1];
176 });
177# $table->add (0, 9, new CFClient::UI::Label valign => 0, align => 1, text => "Effects Volume");
178# $table->add (1, 8, new CFClient::UI::Slider range => [$CFG->{effects_volume}, 0, 128, 1], connect_changed => sub {
179# $CFG->{effects_volume} = $_[1];
180# });
181 $table->add (0, 10, new CFClient::UI::Label valign => 0, align => 1, text => "Background Music");
182 $table->add (1, 10, my $hbox = new CFClient::UI::HBox);
183 $hbox->add (new CFClient::UI::CheckBox expand => 1, state => $CFG->{bgm_enable}, connect_changed => sub {
184 $CFG->{bgm_enable} = $_[1];
185 });
186 $hbox->add (new CFClient::UI::Slider expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0.1], connect_changed => sub {
187 $CFG->{bgm_volume} = $_[1];
188 CFClient::Mix_VolumeMusic ($_[1]);
189 });
190
191 $table->add (1, 11, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub {
192 audio_shutdown ();
193 audio_init ();
172 }); 194 });
173 195
174 $dialog 196 $dialog
175} 197}
176 198
240 $HOST->set_text ($CFG->{host} = $host); 262 $HOST->set_text ($CFG->{host} = $host);
241 }), 263 }),
242 (new CFClient::UI::Empty expand => 1), 264 (new CFClient::UI::Empty expand => 1),
243 ]); 265 ]);
244 266
245 $table->add ($_ + 1, $y, new CFClient::UI::Label align => $align[$_], text => $m->[$_], fontsize => $FONTSIZE * 0.8) 267 $table->add ($_ + 1, $y, new CFClient::UI::Label align => $align[$_], text => $m->[$_], fontsize => 0.8)
246 for 0 .. $#$m; 268 for 0 .. $#$m;
247 } 269 }
248 } 270 }
249 }); 271 });
250} 272}
251 273
252sub server_setup { 274sub server_setup {
253 my $dialog = new CFClient::UI::FancyFrame 275 my $dialog = new CFClient::UI::FancyFrame
254 child => (my $vbox = new CFClient::UI::VBox); 276 child => (my $vbox = new CFClient::UI::VBox);
255 277
256 $vbox->add (new CFClient::UI::Label align => 0, text => "Server Setup"); 278 $vbox->add (new CFClient::UI::Label valign => 0, align => 0, text => "Server Setup");
257 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); 279 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]);
258 $table->add (0, 2, new CFClient::UI::Label align => 1, text => "Host:Port"); 280 $table->add (0, 2, new CFClient::UI::Label valign => 0, align => 1, text => "Host:Port");
259 281
260 { 282 {
261 $table->add (1, 2, my $vbox = new CFClient::UI::VBox); 283 $table->add (1, 2, my $vbox = new CFClient::UI::VBox);
262 284
263 $vbox->add (my $HOST = new CFClient::UI::Entry text => $CFG->{host}, connect_changed => sub { 285 $vbox->add (my $HOST = new CFClient::UI::Entry expand => 1, text => $CFG->{host}, connect_changed => sub {
264 my ($self, $value) = @_; 286 my ($self, $value) = @_;
265 $CFG->{host} = $value; 287 $CFG->{host} = $value;
266 }); 288 });
267 289
268 $METASERVER = metaserver_dialog; 290 $METASERVER = metaserver_dialog;
269 291
270 $vbox->add (new CFClient::UI::Flopper text => "Metaserver", other => $METASERVER, connect_open => sub { 292 $vbox->add (new CFClient::UI::Flopper expand => 1, text => "Metaserver", other => $METASERVER, connect_open => sub {
271 update_metaserver $HOST; 293 update_metaserver $HOST;
272 }); 294 });
273 } 295 }
274 296
275 $table->add (0, 4, new CFClient::UI::Label align => 1, text => "Username"); 297 $table->add (0, 4, new CFClient::UI::Label valign => 0, align => 1, text => "Username");
276 $table->add (1, 4, new CFClient::UI::Entry text => $CFG->{user}, connect_changed => sub { 298 $table->add (1, 4, new CFClient::UI::Entry text => $CFG->{user}, connect_changed => sub {
277 my ($self, $value) = @_; 299 my ($self, $value) = @_;
278 $CFG->{user} = $value; 300 $CFG->{user} = $value;
279 }); 301 });
280 302
281 $table->add (0, 5, new CFClient::UI::Label align => 1, text => "Password"); 303 $table->add (0, 5, new CFClient::UI::Label valign => 0, align => 1, text => "Password");
282 $table->add (1, 5, new CFClient::UI::Entry text => $CFG->{password}, hidden => 1, connect_changed => sub { 304 $table->add (1, 5, new CFClient::UI::Entry text => $CFG->{password}, hidden => 1, connect_changed => sub {
283 my ($self, $value) = @_; 305 my ($self, $value) = @_;
284 $CFG->{password} = $value; 306 $CFG->{password} = $value;
285 }); 307 });
286 308
287 $table->add (0, 6, new CFClient::UI::Label align => 1, text => "Def. say cmd"); 309 $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "Def. say cmd");
288 $table->add (1, 6, my $saycmd = new CFClient::UI::Entry text => $CFG->{say_command}, connect_changed => sub { 310 $table->add (1, 6, my $saycmd = new CFClient::UI::Entry text => $CFG->{say_command}, connect_changed => sub {
289 my ($self, $value) = @_; 311 my ($self, $value) = @_;
290 $CFG->{say_command} = $value; 312 $CFG->{say_command} = $value;
291 }); 313 });
292 314
293 $table->add (0, 7, new CFClient::UI::Label align => 1, text => "Map Size"); 315 $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size");
294 $table->add (1, 7, new CFClient::UI::Slider 316 $table->add (1, 7, new CFClient::UI::Slider
295 req_w => 100, 317 req_w => 100,
296 range => [$CFG->{mapsize}, 10, 100 + 1, 1], 318 range => [$CFG->{mapsize}, 10, 100 + 1, 1],
297 connect_changed => sub { 319 connect_changed => sub {
298 my ($self, $value) = @_; 320 my ($self, $value) = @_;
359 381
360 $window 382 $window
361} 383}
362 384
363sub sdl_init { 385sub sdl_init {
364 #SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE 386 CFClient::SDL_Init
365 SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO
366 and die "SDL::Init failed!\n"; 387 and die "SDL::Init failed!\n";
367} 388}
368 389
369sub video_init { 390sub video_init {
370 sdl_init; 391 sdl_init;
371 392
372 ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; 393 ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] };
373 $FULLSCREEN = $CFG->{fullscreen}; 394 $FULLSCREEN = $CFG->{fullscreen};
374 $FAST = $CFG->{fast}; 395 $FAST = $CFG->{fast};
375 396
376 SDL::GLSetAttribute SDL_GL_RED_SIZE, 5; 397 CFClient::SDL_SetVideoMode $WIDTH, $HEIGHT, $FULLSCREEN
377 SDL::GLSetAttribute SDL_GL_GREEN_SIZE, 5;
378 SDL::GLSetAttribute SDL_GL_BLUE_SIZE, 5;
379 SDL::GLSetAttribute SDL_GL_ALPHA_SIZE, 1;
380
381 SDL::GLSetAttribute SDL_GL_ACCUM_RED_SIZE, 0;
382 SDL::GLSetAttribute SDL_GL_ACCUM_GREEN_SIZE, 0;
383 SDL::GLSetAttribute SDL_GL_ACCUM_BLUE_SIZE, 0;
384 SDL::GLSetAttribute SDL_GL_ACCUM_ALPHA_SIZE, 0;
385
386 SDL::GLSetAttribute SDL_GL_DOUBLEBUFFER, 1;
387 SDL::GLSetAttribute SDL_GL_BUFFER_SIZE, 15;
388 SDL::GLSetAttribute SDL_GL_DEPTH_SIZE, 0;
389
390 SDL::SetVideoMode $WIDTH, $HEIGHT, 0,
391 SDL_HWSURFACE | SDL_ANYFORMAT | SDL_OPENGL | SDL_DOUBLEBUF
392 | ($FULLSCREEN ? SDL_FULLSCREEN : 0)
393 or die "SDL::SetVideoMode failed!\n"; 398 or die "SDL_SetVideoMode failed!\n";
394
395 SDL::WMSetCaption "Crossfire+ Client", "Crossfire+";
396 399
397 $SDL_EV = new SDL::Event; 400 $SDL_EV = new SDL::Event;
398 $SDL_EV->set_unicode (1); 401 $SDL_EV->set_unicode (1);
399 402
400 $SDL_ACTIVE = 1; 403 $SDL_ACTIVE = 1;
401 404
402 $LAST_REFRESH = time - 0.01; 405 $LAST_REFRESH = time - 0.01;
403 406
404 CFClient::gl_init; 407 CFClient::gl_init;
405 408
406 $FONTSIZE = int $HEIGHT / 40; 409 $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize};
407 410
408 ############################################################################# 411 #############################################################################
409 412
410 $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100; 413 $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100;
411 $CFClient::UI::ROOT->add ($DEBUG_STATUS); 414 $DEBUG_STATUS->show;
412 415
413 $STATUS_LINE = new CFClient::UI::Label 416 $STATUS_LINE = new CFClient::UI::Label
414 padding => 0, 417 padding => 0,
415 y => $HEIGHT * 44 / 45 - $FONTSIZE; 418 y => $HEIGHT - $FONTSIZE * 1.8;
416 $CFClient::UI::ROOT->add ($STATUS_LINE); 419 $STATUS_LINE->show;
417 420
418 $ALT_ENTER_MESSAGE = new CFClient::UI::Label 421 $ALT_ENTER_MESSAGE = new CFClient::UI::Label
419 padding => 0, 422 padding => 0,
420 y => $HEIGHT * 44 / 45,
421 fontsize => $HEIGHT / 45, 423 fontsize => 0.8,
422 markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; 424 markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode";
423 $CFClient::UI::ROOT->add ($ALT_ENTER_MESSAGE); 425 $ALT_ENTER_MESSAGE->show;
426 $ALT_ENTER_MESSAGE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h});
424 427
425 $CFClient::UI::ROOT->add ($MAPWIDGET = new CFClient::UI::MapWidget); 428 $CFClient::UI::ROOT->add ($MAPWIDGET = new CFClient::MapWidget);
426 $MAPWIDGET->focus_in; 429 $MAPWIDGET->focus_in;
427 $MAPWIDGET->connect (activate_console => sub { 430 $MAPWIDGET->connect (activate_console => sub {
428 my ($mapwidget, $preset) = @_; 431 my ($mapwidget, $preset) = @_;
429 432
430 if ($CONSOLE) { 433 if ($CONSOLE) {
469} 472}
470 473
471my $bgmusic;#TODO#hack#d# 474my $bgmusic;#TODO#hack#d#
472 475
473sub audio_init { 476sub audio_init {
474 if ($CFG->{sound} || 1) { 477 if ($CFG->{audio_enable}) {
475 if (open my $fh, "<:utf8", CFClient::find_rcfile "sounds/config") { 478 if (open my $fh, "<:utf8", CFClient::find_rcfile "sounds/config") {
476 $SDL_MIXER = new SDL::Mixer; 479
477 $SDL_MIXER->allocate_channels (8); 480 $SDL_MIXER = !CFClient::Mix_OpenAudio;
481 CFClient::Mix_AllocateChannels 8;
482 CFClient::MixMusic::volume $CFG->{bgm_volume};
478 483
484 # TODO: hack, do play loop and mood music
485 if ($CFG->{bgm_enable}) {
479 $bgmusic = new SDL::Music CFClient::find_rcfile "music/game3.ogg"; 486 $bgmusic = new_from_file CFClient::MixMusic CFClient::find_rcfile "music/game3.ogg";
480 $SDL_MIXER->play_music ($bgmusic, -1); 487 $bgmusic->play;
488 }
481 489
482 while (<$fh>) { 490 while (<$fh>) {
483 next if /^\s*#/; 491 next if /^\s*#/;
484 next if /^\s*$/; 492 next if /^\s*$/;
485 493
486 my ($file, $volume, $event) = split /\s+/, $_, 3; 494 my ($file, $volume, $event) = split /\s+/, $_, 3;
487 495
488 push @SOUNDS, "$volume,$file"; 496 push @SOUNDS, "$volume,$file";
489 497
490 $AUDIO_CHUNKS{"$volume,$file"} ||= do { 498 $AUDIO_CHUNKS{"$volume,$file"} ||= do {
491 my $chunk = new SDL::Sound CFClient::find_rcfile "sounds/$file"; 499 my $chunk = new_from_file CFClient::MixChunk CFClient::find_rcfile "sounds/$file";
492 $chunk->volume ($volume * 128 / 100); 500 $chunk->volume ($volume * 128 / 100);
493 $chunk 501 $chunk
494 }; 502 };
495 } 503 }
496 } else { 504 } else {
498 } 506 }
499 } 507 }
500} 508}
501 509
502sub audio_shutdown { 510sub audio_shutdown {
511 CFClient::Mix_CloseAudio if $SDL_MIXER;
503 undef $SDL_MIXER; 512 undef $SDL_MIXER;
504 @SOUNDS = (); 513 @SOUNDS = ();
505 %AUDIO_CHUNKS = (); 514 %AUDIO_CHUNKS = ();
506} 515}
507 516
756} 765}
757 766
758sub conn::sound_play { 767sub conn::sound_play {
759 my ($self, $x, $y, $soundnum, $type) = @_; 768 my ($self, $x, $y, $soundnum, $type) = @_;
760 769
770 $SDL_MIXER
771 or return;
772
761 my $chunk = $AUDIO_CHUNKS{$SOUNDS[$soundnum]} 773 my $chunk = $AUDIO_CHUNKS{$SOUNDS[$soundnum]}
762 or return; 774 or return;
763 775
764 $SDL_MIXER->play_channel (-1, $chunk); 776 $chunk->play;
765 warn "sound $x,$y,$soundnum,$type\n";#d# 777# warn "sound $x,$y,$soundnum,$type\n";#d#
766} 778}
767 779
768sub conn::query { 780sub conn::query {
769 my ($self, $flags, $prompt) = @_; 781 my ($self, $flags, $prompt) = @_;
770 782
771 #TODO 783 #TODO, display dialog with relevant information
772 warn "<<<<QUERY:$flags:$prompt>>>\n";#d# 784 warn "<<<<QUERY:$flags:$prompt>>>\n";#d#
773} 785}
774 786
775sub conn::drawinfo { 787sub conn::drawinfo {
776 my ($self, $color, $text) = @_; 788 my ($self, $color, $text) = @_;
792 ); 804 );
793 805
794 $LOGVIEW->add_paragraph ($color[$color], $text); 806 $LOGVIEW->add_paragraph ($color[$color], $text);
795} 807}
796 808
809sub conn::spell_add {
810 my ($self, $spell) = @_;
811
812 $MAPWIDGET->add_command ("invoke $spell->{name}", $spell->{message}, sub {
813 });
814 $MAPWIDGET->add_command ("cast $spell->{name}", $spell->{message}, sub {
815 });
816}
817
818sub conn::spell_delete {
819 my ($self, $spell) = @_;
820}
821
822sub conn::addme_success {
823 my ($self) = @_;
824
825 for my $skill (values %{$self->{skill_info}}) {
826 $MAPWIDGET->add_command ("ready_skill $skill", "", sub {
827 });
828 $MAPWIDGET->add_command ("use_skill $skill", "", sub {
829 });
830 }
831}
832
797%SDL_CB = ( 833%SDL_CB = (
798 SDL_QUIT() => sub { 834 CFClient::SDL_QUIT => sub {
799 Event::unloop -1; 835 Event::unloop -1;
800 }, 836 },
801 SDL_VIDEORESIZE() => sub { 837 CFClient::SDL_VIDEORESIZE => sub {
802 }, 838 },
803 SDL_VIDEOEXPOSE() => sub { 839 CFClient::SDL_VIDEOEXPOSE => sub {
804 refresh; 840 refresh;
805 }, 841 },
806 SDL_KEYDOWN() => sub { 842 CFClient::SDL_KEYDOWN => sub {
807 if ($SDL_EV->key_mod & KMOD_ALT && $SDL_EV->key_sym == SDLK_RETURN) { 843 if ($SDL_EV->key_mod & CFClient::KMOD_ALT && $SDL_EV->key_sym == 13) {
808 # alt-enter 844 # alt-enter
809 video_shutdown; 845 video_shutdown;
810 $CFG->{fullscreen} = !$CFG->{fullscreen}; 846 $CFG->{fullscreen} = !$CFG->{fullscreen};
811 video_init; 847 video_init;
812 } else { 848 } else {
813 CFClient::UI::feed_sdl_key_down_event ($SDL_EV); 849 CFClient::UI::feed_sdl_key_down_event ($SDL_EV);
814 } 850 }
815 }, 851 },
816 SDL_KEYUP() => sub { 852 CFClient::SDL_KEYUP => sub {
817 CFClient::UI::feed_sdl_key_up_event ($SDL_EV); 853 CFClient::UI::feed_sdl_key_up_event ($SDL_EV);
818 }, 854 },
819 SDL_MOUSEMOTION() => sub { 855 CFClient::SDL_MOUSEMOTION => sub {
820 CFClient::UI::feed_sdl_motion_event ($SDL_EV); 856 CFClient::UI::feed_sdl_motion_event ($SDL_EV);
821 }, 857 },
822 SDL_MOUSEBUTTONDOWN() => sub { 858 CFClient::SDL_MOUSEBUTTONDOWN => sub {
823 CFClient::UI::feed_sdl_button_down_event ($SDL_EV); 859 CFClient::UI::feed_sdl_button_down_event ($SDL_EV);
824 }, 860 },
825 SDL_MOUSEBUTTONUP() => sub { 861 CFClient::SDL_MOUSEBUTTONUP => sub {
826 CFClient::UI::feed_sdl_button_up_event ($SDL_EV); 862 CFClient::UI::feed_sdl_button_up_event ($SDL_EV);
827 }, 863 },
828 SDL_ACTIVEEVENT() => sub { 864 CFClient::SDL_ACTIVEEVENT => sub {
829# printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d# 865# printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d#
830 }, 866 },
831); 867);
832 868
833############################################################################# 869#############################################################################
846 fullscreen => 0, 882 fullscreen => 0,
847 fast => 0, 883 fast => 0,
848 fow_enable => 1, 884 fow_enable => 1,
849 fow_intensity => 0.45, 885 fow_intensity => 0.45,
850 fow_smooth => 0, 886 fow_smooth => 0,
887 gui_fontsize => 1,
851 log_fontsize => 14, 888 log_fontsize => 14,
852 mapsize => 100, 889 mapsize => 100,
853 host => "crossfire.schmorp.de", 890 host => "crossfire.schmorp.de",
854 say_command => 'say', 891 say_command => 'say',
892 audio_enable => 1,
893 bgm_enable => 1,
894 bgm_volume => 64,
855); 895);
856 896
857while (my ($k, $v) = each %DEF_CFG) { 897while (my ($k, $v) = each %DEF_CFG) {
858 $CFG->{$k} = $v unless exists $CFG->{$k}; 898 $CFG->{$k} = $v unless exists $CFG->{$k};
859} 899}
860 900
861sdl_init; 901sdl_init;
862 902
863@SDL_MODES = reverse 903@SDL_MODES = reverse
864 grep $_->[0] >= 640 && $_->[1] >= 480, 904 grep $_->[0] >= 640 && $_->[1] >= 480,
865 map [SDL::RectW ($_), SDL::RectH ($_)], 905 CFClient::SDL_ListModes;
866 @{ SDL::ListModes 0, SDL_FULLSCREEN | SDL_HWSURFACE | SDL_OPENGL };
867 906
868@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)";
869 908
870$CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES; 909$CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES;
871 910

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines