… | |
… | |
3 | use strict; |
3 | use strict; |
4 | use utf8; |
4 | use utf8; |
5 | |
5 | |
6 | use Time::HiRes 'time'; |
6 | use Time::HiRes 'time'; |
7 | use Event; |
7 | use Event; |
8 | |
|
|
9 | use SDL; |
|
|
10 | use SDL::App; |
|
|
11 | use SDL::Event; |
|
|
12 | use SDL::Surface; |
|
|
13 | |
|
|
14 | use SDL::Mixer; |
|
|
15 | use SDL::Sound; |
|
|
16 | use SDL::Music; |
|
|
17 | |
|
|
18 | use SDL::OpenGL; |
|
|
19 | |
8 | |
20 | use Crossfire; |
9 | use Crossfire; |
21 | use Crossfire::Protocol; |
10 | use Crossfire::Protocol; |
22 | |
11 | |
23 | use Compress::LZF; |
12 | use Compress::LZF; |
… | |
… | |
56 | our $LOGVIEW; |
45 | our $LOGVIEW; |
57 | our $CONSOLE; |
46 | our $CONSOLE; |
58 | our $METASERVER; |
47 | our $METASERVER; |
59 | |
48 | |
60 | our $GAUGES; |
49 | our $GAUGES; |
|
|
50 | our $STATWIDS; |
61 | |
51 | |
62 | our $SDL_ACTIVE; |
52 | our $SDL_ACTIVE; |
63 | our $SDL_EV; |
|
|
64 | our %SDL_CB; |
53 | our %SDL_CB; |
65 | |
54 | |
66 | our $SDL_MIXER; |
55 | our $SDL_MIXER; |
67 | our @SOUNDS; # event => file mapping |
56 | our @SOUNDS; # event => file mapping |
68 | our %AUDIO_CHUNKS; # audio files |
57 | our %AUDIO_CHUNKS; # audio files |
… | |
… | |
110 | undef $CONN; |
99 | undef $CONN; |
111 | } |
100 | } |
112 | |
101 | |
113 | sub client_setup { |
102 | sub client_setup { |
114 | my $dialog = new CFClient::UI::FancyFrame |
103 | my $dialog = new CFClient::UI::FancyFrame |
|
|
104 | title => "Client Setup", |
115 | child => (my $vbox = new CFClient::UI::VBox); |
105 | child => (my $vbox = new CFClient::UI::VBox); |
116 | $vbox->add (new CFClient::UI::Label valign => 0, align => 0, text => "Client Setup"); |
|
|
117 | $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); |
106 | $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); |
118 | |
107 | |
119 | $table->add (0, 0, new CFClient::UI::Label valign => 0, align => 1, text => "Video Mode"); |
108 | $table->add (0, 0, new CFClient::UI::Label valign => 0, align => 1, text => "Video Mode"); |
120 | $table->add (1, 0, my $hbox = new CFClient::UI::HBox); |
109 | $table->add (1, 0, my $hbox = new CFClient::UI::HBox); |
121 | |
110 | |
122 | $hbox->add (my $mode_slider = new CFClient::UI::Slider expand => 1, req_w => 100, range => [$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1]); |
111 | $hbox->add (my $mode_slider = new CFClient::UI::Slider expand => 1, req_w => 100, range => [$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1]); |
123 | $hbox->add (my $mode_label = new CFClient::UI::Label valign => 0, height => 0.8); |
112 | $hbox->add (my $mode_label = new CFClient::UI::Label align => 0, valign => 0, height => 0.8, template => "9999x9999"); |
124 | |
113 | |
125 | $mode_slider->connect (changed => sub { |
114 | $mode_slider->connect (changed => sub { |
126 | my ($self, $value) = @_; |
115 | my ($self, $value) = @_; |
127 | |
116 | |
128 | $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value; |
117 | $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value; |
… | |
… | |
188 | $table->add (0, 10, new CFClient::UI::Label valign => 0, align => 1, text => "Background Music"); |
177 | $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); |
178 | $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 { |
179 | $hbox->add (new CFClient::UI::CheckBox expand => 1, state => $CFG->{bgm_enable}, connect_changed => sub { |
191 | $CFG->{bgm_enable} = $_[1]; |
180 | $CFG->{bgm_enable} = $_[1]; |
192 | }); |
181 | }); |
193 | $hbox->add (new CFClient::UI::Slider expand => 1, range => [$CFG->{bgm_volume}, 0, 128, 1], connect_changed => sub { |
182 | $hbox->add (new CFClient::UI::Slider expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0.1], connect_changed => sub { |
194 | $CFG->{bgm_volume} = $_[1]; |
183 | $CFG->{bgm_volume} = $_[1]; |
195 | $SDL_MIXER->music_volume ($_[1]); |
184 | CFClient::MixMusic::volume $_[1] * 128; |
196 | }); |
185 | }); |
197 | |
186 | |
198 | $table->add (1, 11, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { |
187 | $table->add (1, 11, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { |
199 | audio_shutdown (); |
188 | audio_shutdown (); |
200 | audio_init (); |
189 | audio_init (); |
201 | }); |
190 | }); |
202 | |
191 | |
203 | $dialog |
192 | $dialog |
204 | } |
193 | } |
205 | |
194 | |
|
|
195 | sub make_stats_window { |
|
|
196 | my $tgw = new CFClient::UI::FancyFrame (x => $WIDTH * 2/5, y => 0, title => "Stats"); |
|
|
197 | |
|
|
198 | $tgw->add (my $vb = new CFClient::UI::VBox); |
|
|
199 | $vb->add ($STATWIDS->{title} = new CFClient::UI::Label valign => 0, align => -1, text => "Title:"); |
|
|
200 | $vb->add (my $lhb = new CFClient::UI::HBox); |
|
|
201 | $lhb->add ($STATWIDS->{exp} = new CFClient::UI::Label valign => 0, align => -1, text => "Exp:", expand => 1); |
|
|
202 | $lhb->add ($STATWIDS->{lvl} = new CFClient::UI::Label valign => 0, align => -1, text => "Level:", expand => 1); |
|
|
203 | |
|
|
204 | $vb->add (my $hb = new CFClient::UI::HBox expand => 1); |
|
|
205 | $hb->add (my $hg = new CFClient::UI::Gauge type => 'hp', expand => 1); |
|
|
206 | $hb->add (my $mg = new CFClient::UI::Gauge type => 'mana', expand => 1); |
|
|
207 | $hb->add (my $gg = new CFClient::UI::Gauge type => 'grace', expand => 1); |
|
|
208 | $hb->add (my $fg = new CFClient::UI::Gauge type => 'food', expand => 1); |
|
|
209 | $GAUGES = { food => $fg, mana => $mg, hp => $hg, grace => $gg }; |
|
|
210 | |
|
|
211 | $hb->add (my $tbl = new CFClient::UI::Table expand => 1); |
|
|
212 | |
|
|
213 | if (0) { # this code can vanish, just wanted to preserver it for a checkin |
|
|
214 | $tbl->add (0, 0, $STATWIDS->{st_str} = new CFClient::UI::Label valign => 0, align => -1, text => "S"); |
|
|
215 | $tbl->add (0, 1, $STATWIDS->{st_dex} = new CFClient::UI::Label valign => 0, align => -1, text => "D"); |
|
|
216 | $tbl->add (0, 2, $STATWIDS->{st_con} = new CFClient::UI::Label valign => 0, align => -1, text => "Co"); |
|
|
217 | $tbl->add (0, 3, $STATWIDS->{st_int} = new CFClient::UI::Label valign => 0, align => -1, text => "I"); |
|
|
218 | $tbl->add (0, 4, $STATWIDS->{st_wis} = new CFClient::UI::Label valign => 0, align => -1, text => "W"); |
|
|
219 | $tbl->add (0, 5, $STATWIDS->{st_pow} = new CFClient::UI::Label valign => 0, align => -1, text => "P"); |
|
|
220 | $tbl->add (0, 6, $STATWIDS->{st_cha} = new CFClient::UI::Label valign => 0, align => -1, text => "Ch"); |
|
|
221 | |
|
|
222 | $tbl->add (1, 0, $STATWIDS->{st_wc} = new CFClient::UI::Label valign => 0, align => -1, text => "Wc"); |
|
|
223 | $tbl->add (1, 1, $STATWIDS->{st_ac} = new CFClient::UI::Label valign => 0, align => -1, text => "Ac"); |
|
|
224 | $tbl->add (1, 2, $STATWIDS->{st_dam} = new CFClient::UI::Label valign => 0, align => -1, text => "Dam"); |
|
|
225 | $tbl->add (1, 3, $STATWIDS->{st_arm} = new CFClient::UI::Label valign => 0, align => -1, text => "Arm"); |
|
|
226 | $tbl->add (1, 4, $STATWIDS->{st_spd} = new CFClient::UI::Label valign => 0, align => -1, text => "Sp"); |
|
|
227 | $tbl->add (1, 5, $STATWIDS->{st_wspd} = new CFClient::UI::Label valign => 0, align => -1, text => "WSp"); |
|
|
228 | } else { |
|
|
229 | $tbl->add (0, 0, new CFClient::UI::Label valign => 0, align => +1, text => "S"); |
|
|
230 | $tbl->add (0, 1, new CFClient::UI::Label valign => 0, align => +1, text => "D"); |
|
|
231 | $tbl->add (0, 2, new CFClient::UI::Label valign => 0, align => +1, text => "Co"); |
|
|
232 | $tbl->add (0, 3, new CFClient::UI::Label valign => 0, align => +1, text => "I"); |
|
|
233 | $tbl->add (0, 4, new CFClient::UI::Label valign => 0, align => +1, text => "W"); |
|
|
234 | $tbl->add (0, 5, new CFClient::UI::Label valign => 0, align => +1, text => "P"); |
|
|
235 | $tbl->add (0, 6, new CFClient::UI::Label valign => 0, align => +1, text => "Ch"); |
|
|
236 | |
|
|
237 | $tbl->add (1, 0, $STATWIDS->{st_str} = new CFClient::UI::Label valign => 0, align => -1, text => ""); |
|
|
238 | $tbl->add (1, 1, $STATWIDS->{st_dex} = new CFClient::UI::Label valign => 0, align => -1, text => ""); |
|
|
239 | $tbl->add (1, 2, $STATWIDS->{st_con} = new CFClient::UI::Label valign => 0, align => -1, text => ""); |
|
|
240 | $tbl->add (1, 3, $STATWIDS->{st_int} = new CFClient::UI::Label valign => 0, align => -1, text => ""); |
|
|
241 | $tbl->add (1, 4, $STATWIDS->{st_wis} = new CFClient::UI::Label valign => 0, align => -1, text => ""); |
|
|
242 | $tbl->add (1, 5, $STATWIDS->{st_pow} = new CFClient::UI::Label valign => 0, align => -1, text => ""); |
|
|
243 | $tbl->add (1, 6, $STATWIDS->{st_cha} = new CFClient::UI::Label valign => 0, align => -1, text => ""); |
|
|
244 | |
|
|
245 | $tbl->add (2, 0, new CFClient::UI::Label valign => 0, align => +1, text => "Wc"); |
|
|
246 | $tbl->add (2, 1, new CFClient::UI::Label valign => 0, align => +1, text => "Ac"); |
|
|
247 | $tbl->add (2, 2, new CFClient::UI::Label valign => 0, align => +1, text => "Dam"); |
|
|
248 | $tbl->add (2, 3, new CFClient::UI::Label valign => 0, align => +1, text => "Arm"); |
|
|
249 | $tbl->add (2, 4, new CFClient::UI::Label valign => 0, align => +1, text => "Sp"); |
|
|
250 | $tbl->add (2, 5, new CFClient::UI::Label valign => 0, align => +1, text => "WSp"); |
|
|
251 | |
|
|
252 | $tbl->add (3, 0, $STATWIDS->{st_wc} = new CFClient::UI::Label valign => 0, align => -1, text => ""); |
|
|
253 | $tbl->add (3, 1, $STATWIDS->{st_ac} = new CFClient::UI::Label valign => 0, align => -1, text => ""); |
|
|
254 | $tbl->add (3, 2, $STATWIDS->{st_dam} = new CFClient::UI::Label valign => 0, align => -1, text => ""); |
|
|
255 | $tbl->add (3, 3, $STATWIDS->{st_arm} = new CFClient::UI::Label valign => 0, align => -1, text => ""); |
|
|
256 | $tbl->add (3, 4, $STATWIDS->{st_spd} = new CFClient::UI::Label valign => 0, align => -1, text => ""); |
|
|
257 | $tbl->add (3, 5, $STATWIDS->{st_wspd} = new CFClient::UI::Label valign => 0, align => -1, text => ""); |
|
|
258 | } |
|
|
259 | |
|
|
260 | $hb->add (my $tbl2 = new CFClient::UI::Table); |
|
|
261 | |
|
|
262 | my $row = 0; |
|
|
263 | my $col = 0; |
|
|
264 | |
|
|
265 | for (qw/slow holyw conf fire depl magic |
|
|
266 | drain acid pois para deat phys |
|
|
267 | blind fear tund elec cold ghit/) |
|
|
268 | { |
|
|
269 | $tbl2->add ($col, $row, new CFClient::UI::Image image => "ui/resist/resist_$_.png"); |
|
|
270 | $tbl2->add ($col + 1, $row, |
|
|
271 | $STATWIDS->{"res_$_"} = |
|
|
272 | new CFClient::UI::Label text => "0", align => -1, valign => 0 |
|
|
273 | ); |
|
|
274 | |
|
|
275 | $row++; |
|
|
276 | if ($row % 6 == 0) { |
|
|
277 | $col += 2; |
|
|
278 | $row = 0; |
|
|
279 | } |
|
|
280 | } |
|
|
281 | |
|
|
282 | update_stats_window ({}); |
|
|
283 | |
|
|
284 | $tgw |
|
|
285 | } |
|
|
286 | |
|
|
287 | sub update_stats_window { |
|
|
288 | my ($stats) = @_; |
|
|
289 | |
|
|
290 | # i love text protocols!!! |
|
|
291 | my $hp = $stats->{1}; |
|
|
292 | my $hp_m = $stats->{2}; |
|
|
293 | my $sp = $stats->{3}; |
|
|
294 | my $sp_m = $stats->{4}; |
|
|
295 | my $fo = $stats->{18}; |
|
|
296 | my $fo_m = 999; |
|
|
297 | my $gr = $stats->{23}; |
|
|
298 | my $gr_m = $stats->{24}; |
|
|
299 | |
|
|
300 | $GAUGES->{hp} ->set_value ($hp, $hp_m); |
|
|
301 | $GAUGES->{mana} ->set_value ($sp, $sp_m); |
|
|
302 | $GAUGES->{food} ->set_value ($fo, $fo_m); |
|
|
303 | $GAUGES->{grace} ->set_value ($gr, $gr_m); |
|
|
304 | $STATWIDS->{title} ->set_text ("Title: " . $stats->{21}); |
|
|
305 | $STATWIDS->{exp} ->set_text ("Exp.: " . ($stats->{11} || $stats->{28})); |
|
|
306 | $STATWIDS->{lvl} ->set_text ("Level: " . $stats->{12}); |
|
|
307 | |
|
|
308 | if (0) { # this code can vanish, just wanted to preserver it for a checkin |
|
|
309 | $STATWIDS->{st_str} ->set_text (sprintf "S%d", $stats->{5}); |
|
|
310 | $STATWIDS->{st_dex} ->set_text (sprintf "D%d", $stats->{8}); |
|
|
311 | $STATWIDS->{st_con} ->set_text (sprintf "Co%d", $stats->{9}); |
|
|
312 | $STATWIDS->{st_int} ->set_text (sprintf "I%d", $stats->{6}); |
|
|
313 | $STATWIDS->{st_wis} ->set_text (sprintf "W%d", $stats->{7}); |
|
|
314 | $STATWIDS->{st_pow} ->set_text (sprintf "P%d", $stats->{22}); |
|
|
315 | $STATWIDS->{st_cha} ->set_text (sprintf "Ch%d", $stats->{10}); |
|
|
316 | $STATWIDS->{st_wc} ->set_text (sprintf "Wc%d", $stats->{13}); |
|
|
317 | $STATWIDS->{st_ac} ->set_text (sprintf "Ac%d", $stats->{14}); |
|
|
318 | $STATWIDS->{st_dam} ->set_text (sprintf "Dam%d", $stats->{15}); |
|
|
319 | $STATWIDS->{st_arm} ->set_text (sprintf "Arm%d", $stats->{16}); |
|
|
320 | $STATWIDS->{st_spd} ->set_text (sprintf "Sp%.1f", $stats->{17}); |
|
|
321 | $STATWIDS->{st_wspd}->set_text (sprintf "WSp%.1f", $stats->{19}); |
|
|
322 | } else { |
|
|
323 | $STATWIDS->{st_str} ->set_text (sprintf "%d", $stats->{5}); |
|
|
324 | $STATWIDS->{st_dex} ->set_text (sprintf "%d", $stats->{8}); |
|
|
325 | $STATWIDS->{st_con} ->set_text (sprintf "%d", $stats->{9}); |
|
|
326 | $STATWIDS->{st_int} ->set_text (sprintf "%d", $stats->{6}); |
|
|
327 | $STATWIDS->{st_wis} ->set_text (sprintf "%d", $stats->{7}); |
|
|
328 | $STATWIDS->{st_pow} ->set_text (sprintf "%d", $stats->{22}); |
|
|
329 | $STATWIDS->{st_cha} ->set_text (sprintf "%d", $stats->{10}); |
|
|
330 | $STATWIDS->{st_wc} ->set_text (sprintf "%d", $stats->{13}); |
|
|
331 | $STATWIDS->{st_ac} ->set_text (sprintf "%d", $stats->{14}); |
|
|
332 | $STATWIDS->{st_dam} ->set_text (sprintf "%d", $stats->{15}); |
|
|
333 | $STATWIDS->{st_arm} ->set_text (sprintf "%d", $stats->{16}); |
|
|
334 | $STATWIDS->{st_spd} ->set_text (sprintf "%.1f", $stats->{17}); |
|
|
335 | $STATWIDS->{st_wspd}->set_text (sprintf "%.1f", $stats->{19}); |
|
|
336 | } |
|
|
337 | |
|
|
338 | my %tbl = ( |
|
|
339 | phys => 100, |
|
|
340 | magic => 101, |
|
|
341 | fire => 102, |
|
|
342 | elec => 103, |
|
|
343 | cold => 104, |
|
|
344 | conf => 105, |
|
|
345 | acid => 106, |
|
|
346 | drain => 107, |
|
|
347 | ghit => 108, |
|
|
348 | pois => 109, |
|
|
349 | slow => 110, |
|
|
350 | para => 111, |
|
|
351 | tund => 112, |
|
|
352 | fear => 113, |
|
|
353 | deat => 115, |
|
|
354 | holyw => 116, |
|
|
355 | blind => 117 |
|
|
356 | ); |
|
|
357 | |
|
|
358 | for (keys %tbl) { |
|
|
359 | $STATWIDS->{"res_$_"}->set_text (sprintf "%d%", $stats->{$tbl{$_}}); |
|
|
360 | } |
|
|
361 | |
|
|
362 | } |
|
|
363 | |
206 | sub metaserver_dialog { |
364 | sub metaserver_dialog { |
207 | my $dialog = new CFClient::UI::FancyFrame |
365 | my $dialog = new CFClient::UI::FancyFrame |
|
|
366 | title => "Metaserver", |
208 | child => (my $vbox = new CFClient::UI::VBox); |
367 | child => (my $vbox = new CFClient::UI::VBox); |
209 | |
368 | |
210 | $vbox->add ($dialog->{table} = new CFClient::UI::Table); |
369 | $vbox->add ($dialog->{table} = new CFClient::UI::Table); |
211 | |
370 | |
212 | $dialog |
371 | $dialog |
… | |
… | |
278 | }); |
437 | }); |
279 | } |
438 | } |
280 | |
439 | |
281 | sub server_setup { |
440 | sub server_setup { |
282 | my $dialog = new CFClient::UI::FancyFrame |
441 | my $dialog = new CFClient::UI::FancyFrame |
|
|
442 | title => "Server Setup", |
283 | child => (my $vbox = new CFClient::UI::VBox); |
443 | child => (my $vbox = new CFClient::UI::VBox); |
284 | |
444 | |
285 | $vbox->add (new CFClient::UI::Label valign => 0, align => 0, text => "Server Setup"); |
|
|
286 | $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); |
445 | $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); |
287 | $table->add (0, 2, new CFClient::UI::Label valign => 0, align => 1, text => "Host:Port"); |
446 | $table->add (0, 2, new CFClient::UI::Label valign => 0, align => 1, text => "Host:Port"); |
288 | |
447 | |
289 | { |
448 | { |
290 | $table->add (1, 2, my $vbox = new CFClient::UI::VBox); |
449 | $table->add (1, 2, my $vbox = new CFClient::UI::VBox); |
… | |
… | |
337 | $dialog |
496 | $dialog |
338 | } |
497 | } |
339 | |
498 | |
340 | sub message_window { |
499 | sub message_window { |
341 | my $window = new CFClient::UI::FancyFrame |
500 | my $window = new CFClient::UI::FancyFrame |
|
|
501 | title => "Messages", |
342 | border_bg => [1, 1, 1, 0.5], |
502 | border_bg => [1, 1, 1, 0.5], |
343 | bg => [0.3, 0.3, 0.3, 0.8], |
503 | bg => [0.3, 0.3, 0.3, 0.8], |
344 | user_w => int $::WIDTH / 3, |
504 | user_w => int $::WIDTH / 3, |
345 | user_h => int $::HEIGHT / 5, |
505 | user_h => int $::HEIGHT / 5, |
346 | child => (my $vbox = new CFClient::UI::VBox); |
506 | child => (my $vbox = new CFClient::UI::VBox); |
… | |
… | |
388 | |
548 | |
389 | $window |
549 | $window |
390 | } |
550 | } |
391 | |
551 | |
392 | sub sdl_init { |
552 | sub sdl_init { |
393 | #SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE |
553 | CFClient::SDL_Init |
394 | SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO |
|
|
395 | and die "SDL::Init failed!\n"; |
554 | and die "SDL::Init failed!\n"; |
396 | } |
555 | } |
397 | |
556 | |
398 | sub video_init { |
557 | sub video_init { |
399 | sdl_init; |
558 | sdl_init; |
400 | |
559 | |
401 | ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; |
560 | ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; |
402 | $FULLSCREEN = $CFG->{fullscreen}; |
561 | $FULLSCREEN = $CFG->{fullscreen}; |
403 | $FAST = $CFG->{fast}; |
562 | $FAST = $CFG->{fast}; |
404 | |
563 | |
405 | SDL::GLSetAttribute SDL_GL_RED_SIZE, 5; |
564 | CFClient::SDL_SetVideoMode $WIDTH, $HEIGHT, $FULLSCREEN |
406 | SDL::GLSetAttribute SDL_GL_GREEN_SIZE, 5; |
|
|
407 | SDL::GLSetAttribute SDL_GL_BLUE_SIZE, 5; |
|
|
408 | SDL::GLSetAttribute SDL_GL_ALPHA_SIZE, 1; |
|
|
409 | |
|
|
410 | SDL::GLSetAttribute SDL_GL_ACCUM_RED_SIZE, 0; |
|
|
411 | SDL::GLSetAttribute SDL_GL_ACCUM_GREEN_SIZE, 0; |
|
|
412 | SDL::GLSetAttribute SDL_GL_ACCUM_BLUE_SIZE, 0; |
|
|
413 | SDL::GLSetAttribute SDL_GL_ACCUM_ALPHA_SIZE, 0; |
|
|
414 | |
|
|
415 | SDL::GLSetAttribute SDL_GL_DOUBLEBUFFER, 1; |
|
|
416 | SDL::GLSetAttribute SDL_GL_BUFFER_SIZE, 15; |
|
|
417 | SDL::GLSetAttribute SDL_GL_DEPTH_SIZE, 0; |
|
|
418 | |
|
|
419 | SDL::SetVideoMode $WIDTH, $HEIGHT, 0, |
|
|
420 | SDL_HWSURFACE | SDL_ANYFORMAT | SDL_OPENGL | SDL_DOUBLEBUF |
|
|
421 | | ($FULLSCREEN ? SDL_FULLSCREEN : 0) |
|
|
422 | or die "SDL::SetVideoMode failed!\n"; |
565 | or die "SDL_SetVideoMode failed!\n"; |
423 | |
|
|
424 | SDL::WMSetCaption "Crossfire+ Client", "Crossfire+"; |
|
|
425 | |
|
|
426 | $SDL_EV = new SDL::Event; |
|
|
427 | $SDL_EV->set_unicode (1); |
|
|
428 | |
566 | |
429 | $SDL_ACTIVE = 1; |
567 | $SDL_ACTIVE = 1; |
430 | |
568 | |
431 | $LAST_REFRESH = time - 0.01; |
569 | $LAST_REFRESH = time - 0.01; |
432 | |
570 | |
… | |
… | |
477 | status "Configuration Saved"; |
615 | status "Configuration Saved"; |
478 | }); |
616 | }); |
479 | |
617 | |
480 | $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup |
618 | $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup |
481 | |
619 | |
482 | my $tgw = new CFClient::UI::FancyFrame (x => $WIDTH - 300, y => 0); |
|
|
483 | $tgw->add (my $hbox = new CFClient::UI::HBox ()); |
|
|
484 | |
620 | |
485 | $hbox->add (my $hg = new CFClient::UI::VGauge (gauge => 'hp')); |
|
|
486 | $hbox->add (my $mg = new CFClient::UI::VGauge (gauge => 'mana')); |
|
|
487 | $hbox->add (my $gg = new CFClient::UI::VGauge (gauge => 'grace')); |
|
|
488 | $hbox->add (my $fg = new CFClient::UI::VGauge (gauge => 'food')); |
|
|
489 | |
|
|
490 | $GAUGES = { food => $fg, mana => $mg, hp => $hg, grace => $gg }; |
|
|
491 | $CFClient::UI::ROOT->add ($tgw); |
621 | $CFClient::UI::ROOT->add (make_stats_window); |
492 | } |
622 | } |
493 | |
623 | |
494 | sub video_shutdown { |
624 | sub video_shutdown { |
495 | $CFClient::UI::ROOT->{children} = []; |
625 | $CFClient::UI::ROOT->{children} = []; |
496 | undef $SDL_ACTIVE; |
626 | undef $SDL_ACTIVE; |
497 | undef $SDL_EV; |
|
|
498 | } |
627 | } |
499 | |
628 | |
|
|
629 | my @bgmusic = qw(game1.ogg game2.ogg game3.ogg game5.ogg game6.ogg ross1.ogg ross2.ogg ross3.ogg ross4.ogg ross5.ogg); #d# |
500 | my $bgmusic;#TODO#hack#d# |
630 | my $bgmusic;#TODO#hack#d# |
|
|
631 | |
|
|
632 | sub audio_music_finished { |
|
|
633 | return unless $CFG->{bgm_enable}; |
|
|
634 | |
|
|
635 | # TODO: hack, do play loop and mood music |
|
|
636 | $bgmusic = new_from_file CFClient::MixMusic CFClient::find_rcfile "music/$bgmusic[0]"; |
|
|
637 | $bgmusic->play (0); |
|
|
638 | |
|
|
639 | push @bgmusic, shift @bgmusic; |
|
|
640 | } |
501 | |
641 | |
502 | sub audio_init { |
642 | sub audio_init { |
503 | if ($CFG->{audio_enable}) { |
643 | if ($CFG->{audio_enable}) { |
504 | if (open my $fh, "<:utf8", CFClient::find_rcfile "sounds/config") { |
644 | if (open my $fh, "<:utf8", CFClient::find_rcfile "sounds/config") { |
505 | |
645 | $SDL_MIXER = !CFClient::Mix_OpenAudio; |
506 | $SDL_MIXER = new SDL::Mixer |
646 | CFClient::Mix_AllocateChannels 8; |
507 | -rate => 22050, |
647 | CFClient::MixMusic::volume $CFG->{bgm_volume} * 128; |
508 | -channels => 1, # mono |
|
|
509 | -size => 512; |
|
|
510 | |
648 | |
511 | $SDL_MIXER->allocate_channels (8); |
649 | audio_music_finished; |
512 | |
|
|
513 | # TODO: hack, do play loop and mood music |
|
|
514 | if ($CFG->{bgm_enable}) { |
|
|
515 | $bgmusic = new SDL::Music CFClient::find_rcfile "music/game3.ogg"; |
|
|
516 | $SDL_MIXER->play_music ($bgmusic, -1); |
|
|
517 | $SDL_MIXER->music_volume ($CFG->{bgm_volume}); |
|
|
518 | } |
|
|
519 | |
650 | |
520 | while (<$fh>) { |
651 | while (<$fh>) { |
521 | next if /^\s*#/; |
652 | next if /^\s*#/; |
522 | next if /^\s*$/; |
653 | next if /^\s*$/; |
523 | |
654 | |
524 | my ($file, $volume, $event) = split /\s+/, $_, 3; |
655 | my ($file, $volume, $event) = split /\s+/, $_, 3; |
525 | |
656 | |
526 | push @SOUNDS, "$volume,$file"; |
657 | push @SOUNDS, "$volume,$file"; |
527 | |
658 | |
528 | $AUDIO_CHUNKS{"$volume,$file"} ||= do { |
659 | $AUDIO_CHUNKS{"$volume,$file"} ||= do { |
529 | my $chunk = new SDL::Sound CFClient::find_rcfile "sounds/$file"; |
660 | my $chunk = new_from_file CFClient::MixChunk CFClient::find_rcfile "sounds/$file"; |
530 | $chunk->volume ($volume * 128 / 100); |
661 | $chunk->volume ($volume * 128 / 100); |
531 | $chunk |
662 | $chunk |
532 | }; |
663 | }; |
533 | } |
664 | } |
534 | } else { |
665 | } else { |
… | |
… | |
536 | } |
667 | } |
537 | } |
668 | } |
538 | } |
669 | } |
539 | |
670 | |
540 | sub audio_shutdown { |
671 | sub audio_shutdown { |
|
|
672 | CFClient::Mix_CloseAudio if $SDL_MIXER; |
541 | undef $SDL_MIXER; |
673 | undef $SDL_MIXER; |
542 | @SOUNDS = (); |
674 | @SOUNDS = (); |
543 | %AUDIO_CHUNKS = (); |
675 | %AUDIO_CHUNKS = (); |
544 | } |
676 | } |
545 | |
677 | |
… | |
… | |
558 | $want_refresh = 0; |
690 | $want_refresh = 0; |
559 | $can_refresh = 0; |
691 | $can_refresh = 0; |
560 | |
692 | |
561 | $CFClient::UI::ROOT->draw; |
693 | $CFClient::UI::ROOT->draw; |
562 | |
694 | |
563 | SDL::GLSwapBuffers; |
695 | CFClient::SDL_GL_SwapBuffers; |
564 | |
696 | |
565 | $LAST_REFRESH = $NOW; |
697 | $LAST_REFRESH = $NOW; |
566 | } |
698 | } |
567 | |
699 | |
568 | my $refresh_watcher = Event->timer (after => 0, hard => 1, interval => 1 / $MAX_FPS, cb => sub { |
700 | my $refresh_watcher = Event->timer (after => 0, hard => 1, interval => 1 / $MAX_FPS, cb => sub { |
569 | $NOW = time; |
701 | $NOW = time; |
570 | |
702 | |
571 | ($SDL_CB{$SDL_EV->type} || sub { warn "unhandled event ", $SDL_EV->type })->() |
703 | ($SDL_CB{$_->{type}} || sub { warn "unhandled event $_->{type}" })->($_) |
572 | while $SDL_EV->poll; |
704 | for CFClient::SDL_PollEvent; |
573 | |
705 | |
574 | if (%animate_object) { |
706 | if (%animate_object) { |
575 | $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; |
707 | $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; |
576 | $want_refresh++; |
708 | $want_refresh++; |
577 | } |
709 | } |
… | |
… | |
600 | @conn::ISA = Crossfire::Protocol::; |
732 | @conn::ISA = Crossfire::Protocol::; |
601 | |
733 | |
602 | sub conn::stats_update { |
734 | sub conn::stats_update { |
603 | my ($self, $stats) = @_; |
735 | my ($self, $stats) = @_; |
604 | |
736 | |
605 | # i love text protocols!!! |
737 | update_stats_window ($stats); |
606 | # FIXME: the stats are somehow weird |
|
|
607 | my $hp = $stats->{1}; |
|
|
608 | my $hp_m = $stats->{2}; |
|
|
609 | my $sp = $stats->{3}; |
|
|
610 | my $sp_m = $stats->{4}; |
|
|
611 | my $fo = $stats->{18}; |
|
|
612 | my $fo_m = 1000; |
|
|
613 | my $gr = $stats->{23}; |
|
|
614 | my $gr_m = $stats->{24}; |
|
|
615 | |
|
|
616 | #d# warn "DATA $hp $hp_m $sp $sp_m $fo $fo_m $gr $gr_m\n"; |
|
|
617 | $GAUGES->{hp}->set_value ($hp, $hp_m); |
|
|
618 | $GAUGES->{mana}->set_value ($sp, $sp_m); |
|
|
619 | $GAUGES->{food}->set_value ($fo, $fo_m); |
|
|
620 | $GAUGES->{grace}->set_value ($gr, $gr_m); |
|
|
621 | } |
738 | } |
622 | |
739 | |
623 | sub conn::user_send { |
740 | sub conn::user_send { |
624 | my ($self, $command) = @_; |
741 | my ($self, $command) = @_; |
625 | |
742 | |
… | |
… | |
650 | |
767 | |
651 | my ($hash, $x, $y, $w, $h) = @$map_info; |
768 | my ($hash, $x, $y, $w, $h) = @$map_info; |
652 | |
769 | |
653 | my $data = $MAP->get_rect ($x, $y, $w, $h); |
770 | my $data = $MAP->get_rect ($x, $y, $w, $h); |
654 | $MAPCACHE->put ($hash => Compress::LZF::compress $data); |
771 | $MAPCACHE->put ($hash => Compress::LZF::compress $data); |
655 | |
|
|
656 | warn sprintf "SAVEmap[%s] length %d\n", $hash, length $data;#d# |
772 | #warn sprintf "SAVEmap[%s] length %d\n", $hash, length $data;#d# |
657 | |
|
|
658 | } |
773 | } |
659 | |
774 | |
660 | sub conn::map_clear { |
775 | sub conn::map_clear { |
661 | my ($self) = @_; |
776 | my ($self) = @_; |
662 | |
777 | |
663 | $self->flush_map; |
778 | $self->flush_map; |
664 | delete $self->{neigh}; |
779 | delete $self->{neigh_map}; |
665 | |
780 | |
666 | $MAP->clear; |
781 | $MAP->clear; |
667 | } |
782 | } |
668 | |
783 | |
669 | |
784 | |
670 | sub conn::load_map($$$) { |
785 | sub conn::load_map($$$) { |
671 | my ($self, $hash, $x, $y) = @_; |
786 | my ($self, $hash, $x, $y) = @_; |
672 | |
787 | |
673 | if (defined (my $data = $MAPCACHE->get ($hash))) { |
788 | if (defined (my $data = $MAPCACHE->get ($hash))) { |
674 | $data = Compress::LZF::decompress $data; |
789 | $data = Compress::LZF::decompress $data; |
675 | warn sprintf "LOADmap[%s,%d,%d] length %d\n", $hash, $x, $y, length $data;#d# |
790 | #warn sprintf "LOADmap[%s,%d,%d] length %d\n", $hash, $x, $y, length $data;#d# |
676 | for my $id ($MAP->set_rect ($x, $y, $data)) { |
791 | for my $id ($MAP->set_rect ($x, $y, $data)) { |
677 | my $data = $TILECACHE->get ($id) |
792 | my $data = $TILECACHE->get ($id) |
678 | or next; |
793 | or next; |
679 | |
794 | |
680 | $self->set_texture ($id => $data); |
795 | $self->set_texture ($id => $data); |
681 | } |
796 | } |
682 | } |
797 | } |
683 | } |
798 | } |
684 | |
799 | |
|
|
800 | # this method does a "flood fill" into every tile direction |
|
|
801 | # it assumes that tiles are arranged in a rectangular grid, |
|
|
802 | # i.e. a map is the same as the left of the right map etc. |
|
|
803 | # failure to comply are harmless and result in display errors |
|
|
804 | # at worst. |
685 | sub conn::flood_fill { |
805 | sub conn::flood_fill { |
686 | my ($self, $path, $hash, $flags, $x0, $y0, $x1, $y1) = @_; |
806 | my ($self, $gx, $gy, $path, $hash, $flags) = @_; |
687 | |
807 | |
688 | # the server does not allow map paths > 6 |
808 | # the server does not allow map paths > 6 |
689 | return if 6 <= length $path; |
809 | return if 6 <= length $path; |
690 | |
810 | |
691 | for my $tile (1..4) { |
811 | my ($x0, $y0, $x1, $y1) = @{$self->{neigh_rect}}; |
692 | next if $self->{neigh}{$hash}[$tile]; |
812 | |
|
|
813 | for ( |
|
|
814 | [1, 0, -1], |
|
|
815 | [2, 1, 0], |
|
|
816 | [3, 0, 1], |
|
|
817 | [4, -1, 0], |
|
|
818 | ) { |
|
|
819 | my ($tile, $dx, $dy) = @$_; |
|
|
820 | |
|
|
821 | my $gx = $gx + $dx; |
|
|
822 | my $gy = $gy + $dy; |
|
|
823 | |
693 | next unless $flags & (1 << ($tile - 1)); |
824 | next unless $flags & (1 << ($tile - 1)); |
|
|
825 | next if $self->{neigh_grid}{$gx, $gy}++; |
694 | |
826 | |
695 | my $neigh = $self->{neigh}{$hash} ||= []; |
827 | my $neigh = $self->{neigh_map}{$hash} ||= []; |
696 | |
828 | if (my $info = $neigh->[$tile]) { |
697 | $self->send_mapinfo ("spatial $path$tile", sub { |
|
|
698 | my ($mode, $flags, $x, $y, $w, $h, $hash) = @_; |
829 | my ($flags, $x, $y, $w, $h, $hash) = @$info; |
699 | |
830 | |
700 | #warn "map<$path>_$tile=<$mode,$x,$y,$w,$h,$hash>\n";#d# |
|
|
701 | return if $mode ne "spatial"; |
|
|
702 | |
|
|
703 | $x += $MAP->ox; |
|
|
704 | $y += $MAP->oy; |
|
|
705 | |
|
|
706 | $self->load_map ($hash, $x, $y) |
|
|
707 | unless $self->{neigh}{$hash}[5]++;#d# |
|
|
708 | |
|
|
709 | $neigh->[$tile] = [$x, $y, $w, $h]; |
|
|
710 | |
|
|
711 | $self->flood_fill ("$path$tile", $hash, $flags, $x0, $y0, $x1, $y1) |
831 | $self->flood_fill ($gx, $gy, "$path$tile", $hash, $flags) |
712 | if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1; |
832 | if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1; |
|
|
833 | |
|
|
834 | } else { |
|
|
835 | $self->send_mapinfo ("spatial $path$tile", sub { |
|
|
836 | my ($mode, $flags, $x, $y, $w, $h, $hash) = @_; |
|
|
837 | |
|
|
838 | return if $mode ne "spatial"; |
|
|
839 | |
|
|
840 | $x += $MAP->ox; |
|
|
841 | $y += $MAP->oy; |
|
|
842 | |
|
|
843 | $self->load_map ($hash, $x, $y) |
|
|
844 | unless $self->{neigh_map}{$hash}[5]++;#d# |
|
|
845 | |
|
|
846 | $neigh->[$tile] = [$flags, $x, $y, $w, $h, $hash]; |
|
|
847 | |
|
|
848 | $self->flood_fill ($gx, $gy, "$path$tile", $hash, $flags) |
|
|
849 | if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1; |
|
|
850 | }); |
713 | }); |
851 | } |
714 | } |
852 | } |
715 | } |
853 | } |
716 | |
854 | |
717 | sub conn::map_change { |
855 | sub conn::map_change { |
718 | my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_; |
856 | my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_; |
… | |
… | |
721 | |
859 | |
722 | my ($ox, $oy) = ($::MAP->ox, $::MAP->oy); |
860 | my ($ox, $oy) = ($::MAP->ox, $::MAP->oy); |
723 | |
861 | |
724 | my $mapmapw = 250; |
862 | my $mapmapw = 250; |
725 | my $mapmaph = 250; |
863 | my $mapmaph = 250; |
|
|
864 | |
|
|
865 | $self->{neigh_rect} = [ |
|
|
866 | $ox - $mapmapw * 0.5, $oy - $mapmapw * 0.5, |
|
|
867 | $ox + $mapmapw * 0.5 + $w, $oy + $mapmapw * 0.5 + $h, |
|
|
868 | ]; |
726 | |
869 | |
|
|
870 | delete $self->{neigh_grid}; |
727 | $self->flood_fill ("", $hash, $flags, |
871 | $self->flood_fill (0, 0, "", $hash, $flags); |
728 | $ox - $mapmapw * 0.5, $oy - $mapmapw * 0.5, |
|
|
729 | $ox + $mapmapw * 0.5, $oy + $mapmapw * 0.5); |
|
|
730 | |
872 | |
731 | $x += $ox; |
873 | $x += $ox; |
732 | $y += $oy; |
874 | $y += $oy; |
733 | |
875 | |
734 | $self->{map_info} = [$hash, $x, $y, $w, $h]; |
876 | $self->{map_info} = [$hash, $x, $y, $w, $h]; |
… | |
… | |
800 | or return; |
942 | or return; |
801 | |
943 | |
802 | my $chunk = $AUDIO_CHUNKS{$SOUNDS[$soundnum]} |
944 | my $chunk = $AUDIO_CHUNKS{$SOUNDS[$soundnum]} |
803 | or return; |
945 | or return; |
804 | |
946 | |
805 | $SDL_MIXER->play_channel (-1, $chunk); |
947 | $chunk->play; |
806 | # warn "sound $x,$y,$soundnum,$type\n";#d# |
948 | # warn "sound $x,$y,$soundnum,$type\n";#d# |
807 | } |
949 | } |
808 | |
950 | |
809 | sub conn::query { |
951 | sub conn::query { |
810 | my ($self, $flags, $prompt) = @_; |
952 | my ($self, $flags, $prompt) = @_; |
… | |
… | |
858 | }); |
1000 | }); |
859 | } |
1001 | } |
860 | } |
1002 | } |
861 | |
1003 | |
862 | %SDL_CB = ( |
1004 | %SDL_CB = ( |
863 | SDL_QUIT() => sub { |
1005 | CFClient::SDL_QUIT => sub { |
864 | Event::unloop -1; |
1006 | Event::unloop -1; |
865 | }, |
1007 | }, |
866 | SDL_VIDEORESIZE() => sub { |
1008 | CFClient::SDL_VIDEORESIZE => sub { |
867 | }, |
1009 | }, |
868 | SDL_VIDEOEXPOSE() => sub { |
1010 | CFClient::SDL_VIDEOEXPOSE => \&refresh, |
869 | refresh; |
1011 | CFClient::SDL_ACTIVEEVENT => sub { |
|
|
1012 | # printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d# |
870 | }, |
1013 | }, |
871 | SDL_KEYDOWN() => sub { |
1014 | CFClient::SDL_KEYDOWN => sub { |
872 | if ($SDL_EV->key_mod & KMOD_ALT && $SDL_EV->key_sym == SDLK_RETURN) { |
1015 | if ($_[0]{mod} & CFClient::KMOD_ALT && $_[0]{sym} == 13) { |
873 | # alt-enter |
1016 | # alt-enter |
874 | video_shutdown; |
1017 | video_shutdown; |
875 | $CFG->{fullscreen} = !$CFG->{fullscreen}; |
1018 | $CFG->{fullscreen} = !$CFG->{fullscreen}; |
876 | video_init; |
1019 | video_init; |
877 | } else { |
1020 | } else { |
878 | CFClient::UI::feed_sdl_key_down_event ($SDL_EV); |
1021 | CFClient::UI::feed_sdl_key_down_event ($_[0]); |
879 | } |
1022 | } |
880 | }, |
1023 | }, |
881 | SDL_KEYUP() => sub { |
1024 | CFClient::SDL_KEYUP => \&CFClient::UI::feed_sdl_key_up_event, |
882 | CFClient::UI::feed_sdl_key_up_event ($SDL_EV); |
1025 | CFClient::SDL_MOUSEMOTION => \&CFClient::UI::feed_sdl_motion_event, |
883 | }, |
1026 | CFClient::SDL_MOUSEBUTTONDOWN => \&CFClient::UI::feed_sdl_button_down_event, |
884 | SDL_MOUSEMOTION() => sub { |
1027 | CFClient::SDL_MOUSEBUTTONUP => \&CFClient::UI::feed_sdl_button_up_event, |
885 | CFClient::UI::feed_sdl_motion_event ($SDL_EV); |
1028 | CFClient::SDL_USEREVENT => \&audio_music_finished, |
886 | }, |
|
|
887 | SDL_MOUSEBUTTONDOWN() => sub { |
|
|
888 | CFClient::UI::feed_sdl_button_down_event ($SDL_EV); |
|
|
889 | }, |
|
|
890 | SDL_MOUSEBUTTONUP() => sub { |
|
|
891 | CFClient::UI::feed_sdl_button_up_event ($SDL_EV); |
|
|
892 | }, |
|
|
893 | SDL_ACTIVEEVENT() => sub { |
|
|
894 | # printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d# |
|
|
895 | }, |
|
|
896 | ); |
1029 | ); |
897 | |
1030 | |
898 | ############################################################################# |
1031 | ############################################################################# |
899 | |
1032 | |
900 | $SIG{INT} = $SIG{TERM} = sub { exit }; |
1033 | $SIG{INT} = $SIG{TERM} = sub { exit }; |
… | |
… | |
918 | mapsize => 100, |
1051 | mapsize => 100, |
919 | host => "crossfire.schmorp.de", |
1052 | host => "crossfire.schmorp.de", |
920 | say_command => 'say', |
1053 | say_command => 'say', |
921 | audio_enable => 1, |
1054 | audio_enable => 1, |
922 | bgm_enable => 1, |
1055 | bgm_enable => 1, |
923 | bgm_volume => 64, |
1056 | bgm_volume => 0.25, |
924 | ); |
1057 | ); |
925 | |
1058 | |
926 | while (my ($k, $v) = each %DEF_CFG) { |
1059 | while (my ($k, $v) = each %DEF_CFG) { |
927 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
1060 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
928 | } |
1061 | } |
929 | |
1062 | |
930 | sdl_init; |
1063 | sdl_init; |
931 | |
1064 | |
932 | @SDL_MODES = reverse |
1065 | @SDL_MODES = reverse |
933 | grep $_->[0] >= 640 && $_->[1] >= 480, |
1066 | grep $_->[0] >= 640 && $_->[1] >= 480, |
934 | map [SDL::RectW ($_), SDL::RectH ($_)], |
1067 | CFClient::SDL_ListModes; |
935 | @{ SDL::ListModes 0, SDL_FULLSCREEN | SDL_HWSURFACE | SDL_OPENGL }; |
|
|
936 | |
1068 | |
937 | @SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; |
1069 | @SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; |
938 | |
1070 | |
939 | $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES; |
1071 | $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES; |
940 | |
1072 | |
… | |
… | |
948 | video_init; |
1080 | video_init; |
949 | audio_init; |
1081 | audio_init; |
950 | |
1082 | |
951 | Event::loop; |
1083 | Event::loop; |
952 | |
1084 | |
953 | END { SDL::Quit } |
1085 | END { CFClient::SDL_Quit } |
954 | |
1086 | |
955 | |
1087 | |