… | |
… | |
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 | |
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 | |
|
|
20 | use Crossfire; |
9 | use Crossfire; |
21 | use Crossfire::Protocol; |
10 | use Crossfire::Protocol; |
22 | |
11 | |
23 | use Compress::LZF; |
12 | use Compress::LZF; |
24 | |
13 | |
25 | use CFClient; |
14 | use CFClient; |
26 | use CFClient::UI; |
15 | use CFClient::UI; |
|
|
16 | use CFClient::MapWidget; |
27 | |
17 | |
28 | our $VERSION = '0.1'; |
18 | our $VERSION = '0.1'; |
29 | |
19 | |
30 | my $MAX_FPS = 60; |
20 | my $MAX_FPS = 60; |
31 | my $MIN_FPS = 5; # unused as of yet |
21 | my $MIN_FPS = 5; # unused as of yet |
… | |
… | |
57 | our $METASERVER; |
47 | our $METASERVER; |
58 | |
48 | |
59 | our $GAUGES; |
49 | our $GAUGES; |
60 | |
50 | |
61 | our $SDL_ACTIVE; |
51 | our $SDL_ACTIVE; |
62 | our $SDL_EV; |
|
|
63 | our %SDL_CB; |
52 | our %SDL_CB; |
64 | |
53 | |
65 | our $SDL_MIXER; |
54 | our $SDL_MIXER; |
66 | our @SOUNDS; # event => file mapping |
55 | our @SOUNDS; # event => file mapping |
67 | our %AUDIO_CHUNKS; # audio files |
56 | our %AUDIO_CHUNKS; # audio files |
… | |
… | |
109 | undef $CONN; |
98 | undef $CONN; |
110 | } |
99 | } |
111 | |
100 | |
112 | sub client_setup { |
101 | sub client_setup { |
113 | my $dialog = new CFClient::UI::FancyFrame |
102 | my $dialog = new CFClient::UI::FancyFrame |
|
|
103 | title => "Client Setup", |
114 | child => (my $vbox = new CFClient::UI::VBox); |
104 | child => (my $vbox = new CFClient::UI::VBox); |
115 | $vbox->add (new CFClient::UI::Label align => 0, text => "Client Setup"); |
|
|
116 | $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); |
105 | $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); |
117 | |
106 | |
118 | $table->add (0, 0, new CFClient::UI::Label align => 1, text => "Video Mode"); |
107 | $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); |
108 | $table->add (1, 0, my $hbox = new CFClient::UI::HBox); |
120 | |
109 | |
121 | $hbox->add (my $mode_slider = new CFClient::UI::Slider expand => 1, req_w => 100, range => [$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1]); |
110 | $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); |
111 | $hbox->add (my $mode_label = new CFClient::UI::Label align => 0, valign => 0, height => 0.8, template => "9999x9999"); |
123 | |
112 | |
124 | $mode_slider->connect (changed => sub { |
113 | $mode_slider->connect (changed => sub { |
125 | my ($self, $value) = @_; |
114 | my ($self, $value) = @_; |
126 | |
115 | |
127 | $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value; |
116 | $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value; |
128 | $mode_label->set_text (sprintf "%dx%d", @{$SDL_MODES[$value]}); |
117 | $mode_label->set_text (sprintf "%dx%d", @{$SDL_MODES[$value]}); |
129 | }); |
118 | }); |
130 | $mode_slider->emit (changed => $mode_slider->{range}[0]); |
119 | $mode_slider->emit (changed => $mode_slider->{range}[0]); |
131 | |
120 | |
132 | $table->add (0, 1, new CFClient::UI::Label align => 1, text => "Fullscreen"); |
121 | $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 { |
122 | $table->add (1, 1, new CFClient::UI::CheckBox state => $CFG->{fullscreen}, connect_changed => sub { |
134 | my ($self, $value) = @_; |
123 | my ($self, $value) = @_; |
135 | $CFG->{fullscreen} = $value; |
124 | $CFG->{fullscreen} = $value; |
136 | }); |
125 | }); |
137 | |
126 | |
138 | $table->add (0, 2, new CFClient::UI::Label align => 1, text => "Fast & Ugly"); |
127 | $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 { |
128 | $table->add (1, 2, new CFClient::UI::CheckBox state => $CFG->{fast}, connect_changed => sub { |
140 | my ($self, $value) = @_; |
129 | my ($self, $value) = @_; |
141 | $CFG->{fast} = $value; |
130 | $CFG->{fast} = $value; |
142 | }); |
131 | }); |
143 | |
132 | |
144 | $table->add (0, 3, new CFClient::UI::Label align => 1, text => "Fog of War"); |
133 | $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 { |
134 | $table->add (1, 3, new CFClient::UI::CheckBox state => $CFG->{fow_enable}, connect_changed => sub { |
146 | my ($self, $value) = @_; |
135 | my ($self, $value) = @_; |
147 | $CFG->{fow_enable} = $value; |
136 | $CFG->{fow_enable} = $value; |
148 | }); |
137 | }); |
149 | |
138 | |
150 | $table->add (0, 4, new CFClient::UI::Label align => 1, text => "FoW Intensity"); |
139 | $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 { |
140 | $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) = @_; |
141 | my ($self, $value) = @_; |
153 | $CFG->{fow_intensity} = $value; |
142 | $CFG->{fow_intensity} = $value; |
154 | }); |
143 | }); |
155 | |
144 | |
156 | $table->add (0, 5, new CFClient::UI::Label align => 1, text => "FoW Smooth"); |
145 | $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 { |
146 | $table->add (1, 5, new CFClient::UI::CheckBox state => $CFG->{fow_smooth}, connect_changed => sub { |
158 | my ($self, $value) = @_; |
147 | my ($self, $value) = @_; |
159 | $CFG->{fow_smooth} = $value; |
148 | $CFG->{fow_smooth} = $value; |
160 | status "Fog of War smoothing requires OpenGL 1.2 or higher" if $CFClient::GL_VERSION < 1.2; |
149 | status "Fog of War smoothing requires OpenGL 1.2 or higher" if $CFClient::GL_VERSION < 1.2; |
161 | }); |
150 | }); |
162 | |
151 | |
163 | $table->add (0, 6, new CFClient::UI::Label align => 1, text => "Log Fontsize"); |
152 | $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "GUI Fontsize"); |
|
|
153 | $table->add (1, 6, new CFClient::UI::Slider range => [$CFG->{gui_fontsize}, 0.7, 1.7, 0.1], connect_changed => sub { |
|
|
154 | $CFG->{gui_fontsize} = 0.1 * int $_[1] * 10; |
|
|
155 | # $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize}; |
|
|
156 | }); |
|
|
157 | |
|
|
158 | $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 { |
159 | $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); |
160 | $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = 0.1 * int $_[1] * 10); |
167 | }); |
161 | }); |
168 | |
162 | |
169 | $table->add (1, 7, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { |
163 | $table->add (1, 8, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { |
170 | video_shutdown (); |
164 | video_shutdown (); |
171 | video_init (); |
165 | video_init (); |
172 | }); |
166 | }); |
173 | |
167 | |
|
|
168 | $table->add (0, 9, new CFClient::UI::Label valign => 0, align => 1, text => "Audio Enable"); |
|
|
169 | $table->add (1, 9, new CFClient::UI::CheckBox state => $CFG->{audio_enable}, connect_changed => sub { |
|
|
170 | $CFG->{audio_enable} = $_[1]; |
|
|
171 | }); |
|
|
172 | # $table->add (0, 9, new CFClient::UI::Label valign => 0, align => 1, text => "Effects Volume"); |
|
|
173 | # $table->add (1, 8, new CFClient::UI::Slider range => [$CFG->{effects_volume}, 0, 128, 1], connect_changed => sub { |
|
|
174 | # $CFG->{effects_volume} = $_[1]; |
|
|
175 | # }); |
|
|
176 | $table->add (0, 10, new CFClient::UI::Label valign => 0, align => 1, text => "Background Music"); |
|
|
177 | $table->add (1, 10, my $hbox = new CFClient::UI::HBox); |
|
|
178 | $hbox->add (new CFClient::UI::CheckBox expand => 1, state => $CFG->{bgm_enable}, connect_changed => sub { |
|
|
179 | $CFG->{bgm_enable} = $_[1]; |
|
|
180 | }); |
|
|
181 | $hbox->add (new CFClient::UI::Slider expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0.1], connect_changed => sub { |
|
|
182 | $CFG->{bgm_volume} = $_[1]; |
|
|
183 | CFClient::MixMusic::volume $_[1] * 128; |
|
|
184 | }); |
|
|
185 | |
|
|
186 | $table->add (1, 11, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { |
|
|
187 | audio_shutdown (); |
|
|
188 | audio_init (); |
|
|
189 | }); |
|
|
190 | |
174 | $dialog |
191 | $dialog |
175 | } |
192 | } |
176 | |
193 | |
177 | sub metaserver_dialog { |
194 | sub metaserver_dialog { |
178 | my $dialog = new CFClient::UI::FancyFrame |
195 | my $dialog = new CFClient::UI::FancyFrame |
|
|
196 | title => "Metaserver", |
179 | child => (my $vbox = new CFClient::UI::VBox); |
197 | child => (my $vbox = new CFClient::UI::VBox); |
180 | |
198 | |
181 | $vbox->add ($dialog->{table} = new CFClient::UI::Table); |
199 | $vbox->add ($dialog->{table} = new CFClient::UI::Table); |
182 | |
200 | |
183 | $dialog |
201 | $dialog |
… | |
… | |
240 | $HOST->set_text ($CFG->{host} = $host); |
258 | $HOST->set_text ($CFG->{host} = $host); |
241 | }), |
259 | }), |
242 | (new CFClient::UI::Empty expand => 1), |
260 | (new CFClient::UI::Empty expand => 1), |
243 | ]); |
261 | ]); |
244 | |
262 | |
245 | $table->add ($_ + 1, $y, new CFClient::UI::Label align => $align[$_], text => $m->[$_], fontsize => $FONTSIZE * 0.8) |
263 | $table->add ($_ + 1, $y, new CFClient::UI::Label align => $align[$_], text => $m->[$_], fontsize => 0.8) |
246 | for 0 .. $#$m; |
264 | for 0 .. $#$m; |
247 | } |
265 | } |
248 | } |
266 | } |
249 | }); |
267 | }); |
250 | } |
268 | } |
251 | |
269 | |
252 | sub server_setup { |
270 | sub server_setup { |
253 | my $dialog = new CFClient::UI::FancyFrame |
271 | my $dialog = new CFClient::UI::FancyFrame |
|
|
272 | title => "Server Setup", |
254 | child => (my $vbox = new CFClient::UI::VBox); |
273 | child => (my $vbox = new CFClient::UI::VBox); |
255 | |
274 | |
256 | $vbox->add (new CFClient::UI::Label align => 0, text => "Server Setup"); |
|
|
257 | $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); |
275 | $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"); |
276 | $table->add (0, 2, new CFClient::UI::Label valign => 0, align => 1, text => "Host:Port"); |
259 | |
277 | |
260 | { |
278 | { |
261 | $table->add (1, 2, my $vbox = new CFClient::UI::VBox); |
279 | $table->add (1, 2, my $vbox = new CFClient::UI::VBox); |
262 | |
280 | |
263 | $vbox->add (my $HOST = new CFClient::UI::Entry text => $CFG->{host}, connect_changed => sub { |
281 | $vbox->add (my $HOST = new CFClient::UI::Entry expand => 1, text => $CFG->{host}, connect_changed => sub { |
264 | my ($self, $value) = @_; |
282 | my ($self, $value) = @_; |
265 | $CFG->{host} = $value; |
283 | $CFG->{host} = $value; |
266 | }); |
284 | }); |
267 | |
285 | |
268 | $METASERVER = metaserver_dialog; |
286 | $METASERVER = metaserver_dialog; |
269 | |
287 | |
270 | $vbox->add (new CFClient::UI::Flopper text => "Metaserver", other => $METASERVER, connect_open => sub { |
288 | $vbox->add (new CFClient::UI::Flopper expand => 1, text => "Metaserver", other => $METASERVER, connect_open => sub { |
271 | update_metaserver $HOST; |
289 | update_metaserver $HOST; |
272 | }); |
290 | }); |
273 | } |
291 | } |
274 | |
292 | |
275 | $table->add (0, 4, new CFClient::UI::Label align => 1, text => "Username"); |
293 | $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 { |
294 | $table->add (1, 4, new CFClient::UI::Entry text => $CFG->{user}, connect_changed => sub { |
277 | my ($self, $value) = @_; |
295 | my ($self, $value) = @_; |
278 | $CFG->{user} = $value; |
296 | $CFG->{user} = $value; |
279 | }); |
297 | }); |
280 | |
298 | |
281 | $table->add (0, 5, new CFClient::UI::Label align => 1, text => "Password"); |
299 | $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 { |
300 | $table->add (1, 5, new CFClient::UI::Entry text => $CFG->{password}, hidden => 1, connect_changed => sub { |
283 | my ($self, $value) = @_; |
301 | my ($self, $value) = @_; |
284 | $CFG->{password} = $value; |
302 | $CFG->{password} = $value; |
285 | }); |
303 | }); |
286 | |
304 | |
287 | $table->add (0, 6, new CFClient::UI::Label align => 1, text => "Def. say cmd"); |
305 | $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 { |
306 | $table->add (1, 6, my $saycmd = new CFClient::UI::Entry text => $CFG->{say_command}, connect_changed => sub { |
289 | my ($self, $value) = @_; |
307 | my ($self, $value) = @_; |
290 | $CFG->{say_command} = $value; |
308 | $CFG->{say_command} = $value; |
291 | }); |
309 | }); |
292 | |
310 | |
293 | $table->add (0, 7, new CFClient::UI::Label align => 1, text => "Map Size"); |
311 | $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size"); |
294 | $table->add (1, 7, new CFClient::UI::Slider |
312 | $table->add (1, 7, new CFClient::UI::Slider |
295 | req_w => 100, |
313 | req_w => 100, |
296 | range => [$CFG->{mapsize}, 10, 100 + 1, 1], |
314 | range => [$CFG->{mapsize}, 10, 100 + 1, 1], |
297 | connect_changed => sub { |
315 | connect_changed => sub { |
298 | my ($self, $value) = @_; |
316 | my ($self, $value) = @_; |
… | |
… | |
308 | $dialog |
326 | $dialog |
309 | } |
327 | } |
310 | |
328 | |
311 | sub message_window { |
329 | sub message_window { |
312 | my $window = new CFClient::UI::FancyFrame |
330 | my $window = new CFClient::UI::FancyFrame |
|
|
331 | title => "Messages", |
313 | border_bg => [1, 1, 1, 0.5], |
332 | border_bg => [1, 1, 1, 0.5], |
314 | bg => [0.3, 0.3, 0.3, 0.8], |
333 | bg => [0.3, 0.3, 0.3, 0.8], |
315 | user_w => int $::WIDTH / 3, |
334 | user_w => int $::WIDTH / 3, |
316 | user_h => int $::HEIGHT / 5, |
335 | user_h => int $::HEIGHT / 5, |
317 | child => (my $vbox = new CFClient::UI::VBox); |
336 | child => (my $vbox = new CFClient::UI::VBox); |
… | |
… | |
359 | |
378 | |
360 | $window |
379 | $window |
361 | } |
380 | } |
362 | |
381 | |
363 | sub sdl_init { |
382 | sub sdl_init { |
364 | #SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE |
383 | CFClient::SDL_Init |
365 | SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO |
|
|
366 | and die "SDL::Init failed!\n"; |
384 | and die "SDL::Init failed!\n"; |
367 | } |
385 | } |
368 | |
386 | |
369 | sub video_init { |
387 | sub video_init { |
370 | sdl_init; |
388 | sdl_init; |
371 | |
389 | |
372 | ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; |
390 | ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; |
373 | $FULLSCREEN = $CFG->{fullscreen}; |
391 | $FULLSCREEN = $CFG->{fullscreen}; |
374 | $FAST = $CFG->{fast}; |
392 | $FAST = $CFG->{fast}; |
375 | |
393 | |
376 | SDL::GLSetAttribute SDL_GL_RED_SIZE, 5; |
394 | 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"; |
395 | or die "SDL_SetVideoMode failed!\n"; |
394 | |
|
|
395 | SDL::WMSetCaption "Crossfire+ Client", "Crossfire+"; |
|
|
396 | |
|
|
397 | $SDL_EV = new SDL::Event; |
|
|
398 | $SDL_EV->set_unicode (1); |
|
|
399 | |
396 | |
400 | $SDL_ACTIVE = 1; |
397 | $SDL_ACTIVE = 1; |
401 | |
398 | |
402 | $LAST_REFRESH = time - 0.01; |
399 | $LAST_REFRESH = time - 0.01; |
403 | |
400 | |
404 | CFClient::gl_init; |
401 | CFClient::gl_init; |
405 | |
402 | |
406 | $FONTSIZE = int $HEIGHT / 40; |
403 | $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize}; |
407 | |
404 | |
408 | ############################################################################# |
405 | ############################################################################# |
409 | |
406 | |
410 | $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100; |
407 | $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100; |
411 | $CFClient::UI::ROOT->add ($DEBUG_STATUS); |
408 | $DEBUG_STATUS->show; |
412 | |
409 | |
413 | $STATUS_LINE = new CFClient::UI::Label |
410 | $STATUS_LINE = new CFClient::UI::Label |
414 | padding => 0, |
411 | padding => 0, |
415 | y => $HEIGHT * 44 / 45 - $FONTSIZE; |
412 | y => $HEIGHT - $FONTSIZE * 1.8; |
416 | $CFClient::UI::ROOT->add ($STATUS_LINE); |
413 | $STATUS_LINE->show; |
417 | |
414 | |
418 | $ALT_ENTER_MESSAGE = new CFClient::UI::Label |
415 | $ALT_ENTER_MESSAGE = new CFClient::UI::Label |
419 | padding => 0, |
416 | padding => 0, |
420 | y => $HEIGHT * 44 / 45, |
|
|
421 | fontsize => $HEIGHT / 45, |
417 | fontsize => 0.8, |
422 | markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; |
418 | markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; |
423 | $CFClient::UI::ROOT->add ($ALT_ENTER_MESSAGE); |
419 | $ALT_ENTER_MESSAGE->show; |
|
|
420 | $ALT_ENTER_MESSAGE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h}); |
424 | |
421 | |
425 | $CFClient::UI::ROOT->add ($MAPWIDGET = new CFClient::UI::MapWidget); |
422 | $CFClient::UI::ROOT->add ($MAPWIDGET = new CFClient::MapWidget); |
426 | $MAPWIDGET->focus_in; |
423 | $MAPWIDGET->focus_in; |
427 | $MAPWIDGET->connect (activate_console => sub { |
424 | $MAPWIDGET->connect (activate_console => sub { |
428 | my ($mapwidget, $preset) = @_; |
425 | my ($mapwidget, $preset) = @_; |
429 | |
426 | |
430 | if ($CONSOLE) { |
427 | if ($CONSOLE) { |
… | |
… | |
448 | status "Configuration Saved"; |
445 | status "Configuration Saved"; |
449 | }); |
446 | }); |
450 | |
447 | |
451 | $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup |
448 | $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup |
452 | |
449 | |
453 | my $tgw = new CFClient::UI::FancyFrame (x => $WIDTH - 300, y => 0); |
450 | my $tgw = new CFClient::UI::FancyFrame (x => $WIDTH - 300, y => 0, title => "Stats"); |
454 | $tgw->add (my $hbox = new CFClient::UI::HBox ()); |
451 | $tgw->add (my $hbox = new CFClient::UI::HBox ()); |
455 | |
452 | |
456 | $hbox->add (my $hg = new CFClient::UI::VGauge (gauge => 'hp')); |
453 | $hbox->add (my $hg = new CFClient::UI::Gauge (type => 'hp')); |
457 | $hbox->add (my $mg = new CFClient::UI::VGauge (gauge => 'mana')); |
454 | $hbox->add (my $mg = new CFClient::UI::Gauge (type => 'mana')); |
458 | $hbox->add (my $gg = new CFClient::UI::VGauge (gauge => 'grace')); |
455 | $hbox->add (my $gg = new CFClient::UI::Gauge (type => 'grace')); |
459 | $hbox->add (my $fg = new CFClient::UI::VGauge (gauge => 'food')); |
456 | $hbox->add (my $fg = new CFClient::UI::Gauge (type => 'food')); |
460 | |
457 | |
461 | $GAUGES = { food => $fg, mana => $mg, hp => $hg, grace => $gg }; |
458 | $GAUGES = { food => $fg, mana => $mg, hp => $hg, grace => $gg }; |
462 | $CFClient::UI::ROOT->add ($tgw); |
459 | $CFClient::UI::ROOT->add ($tgw); |
463 | } |
460 | } |
464 | |
461 | |
465 | sub video_shutdown { |
462 | sub video_shutdown { |
466 | $CFClient::UI::ROOT->{children} = []; |
463 | $CFClient::UI::ROOT->{children} = []; |
467 | undef $SDL_ACTIVE; |
464 | undef $SDL_ACTIVE; |
468 | undef $SDL_EV; |
|
|
469 | } |
465 | } |
470 | |
466 | |
471 | my $bgmusic;#TODO#hack#d# |
467 | my $bgmusic;#TODO#hack#d# |
472 | |
468 | |
473 | sub audio_init { |
469 | sub audio_init { |
474 | if ($CFG->{sound} || 1) { |
470 | if ($CFG->{audio_enable}) { |
475 | if (open my $fh, "<:utf8", CFClient::find_rcfile "sounds/config") { |
471 | if (open my $fh, "<:utf8", CFClient::find_rcfile "sounds/config") { |
476 | $SDL_MIXER = new SDL::Mixer; |
472 | |
477 | $SDL_MIXER->allocate_channels (8); |
473 | $SDL_MIXER = !CFClient::Mix_OpenAudio; |
|
|
474 | CFClient::Mix_AllocateChannels 8; |
|
|
475 | CFClient::MixMusic::volume $CFG->{bgm_volume} * 128; |
478 | |
476 | |
|
|
477 | # TODO: hack, do play loop and mood music |
|
|
478 | if ($CFG->{bgm_enable}) { |
479 | $bgmusic = new SDL::Music CFClient::find_rcfile "music/game3.ogg"; |
479 | $bgmusic = new_from_file CFClient::MixMusic CFClient::find_rcfile "music/game3.ogg"; |
480 | $SDL_MIXER->play_music ($bgmusic, -1); |
480 | $bgmusic->play; |
|
|
481 | } |
481 | |
482 | |
482 | while (<$fh>) { |
483 | while (<$fh>) { |
483 | next if /^\s*#/; |
484 | next if /^\s*#/; |
484 | next if /^\s*$/; |
485 | next if /^\s*$/; |
485 | |
486 | |
486 | my ($file, $volume, $event) = split /\s+/, $_, 3; |
487 | my ($file, $volume, $event) = split /\s+/, $_, 3; |
487 | |
488 | |
488 | push @SOUNDS, "$volume,$file"; |
489 | push @SOUNDS, "$volume,$file"; |
489 | |
490 | |
490 | $AUDIO_CHUNKS{"$volume,$file"} ||= do { |
491 | $AUDIO_CHUNKS{"$volume,$file"} ||= do { |
491 | my $chunk = new SDL::Sound CFClient::find_rcfile "sounds/$file"; |
492 | my $chunk = new_from_file CFClient::MixChunk CFClient::find_rcfile "sounds/$file"; |
492 | $chunk->volume ($volume * 128 / 100); |
493 | $chunk->volume ($volume * 128 / 100); |
493 | $chunk |
494 | $chunk |
494 | }; |
495 | }; |
495 | } |
496 | } |
496 | } else { |
497 | } else { |
… | |
… | |
498 | } |
499 | } |
499 | } |
500 | } |
500 | } |
501 | } |
501 | |
502 | |
502 | sub audio_shutdown { |
503 | sub audio_shutdown { |
|
|
504 | CFClient::Mix_CloseAudio if $SDL_MIXER; |
503 | undef $SDL_MIXER; |
505 | undef $SDL_MIXER; |
504 | @SOUNDS = (); |
506 | @SOUNDS = (); |
505 | %AUDIO_CHUNKS = (); |
507 | %AUDIO_CHUNKS = (); |
506 | } |
508 | } |
507 | |
509 | |
… | |
… | |
520 | $want_refresh = 0; |
522 | $want_refresh = 0; |
521 | $can_refresh = 0; |
523 | $can_refresh = 0; |
522 | |
524 | |
523 | $CFClient::UI::ROOT->draw; |
525 | $CFClient::UI::ROOT->draw; |
524 | |
526 | |
525 | SDL::GLSwapBuffers; |
527 | CFClient::SDL_GL_SwapBuffers; |
526 | |
528 | |
527 | $LAST_REFRESH = $NOW; |
529 | $LAST_REFRESH = $NOW; |
528 | } |
530 | } |
529 | |
531 | |
530 | my $refresh_watcher = Event->timer (after => 0, hard => 1, interval => 1 / $MAX_FPS, cb => sub { |
532 | my $refresh_watcher = Event->timer (after => 0, hard => 1, interval => 1 / $MAX_FPS, cb => sub { |
531 | $NOW = time; |
533 | $NOW = time; |
532 | |
534 | |
533 | ($SDL_CB{$SDL_EV->type} || sub { warn "unhandled event ", $SDL_EV->type })->() |
535 | ($SDL_CB{$_->{type}} || sub { warn "unhandled event $_->{type}" })->($_) |
534 | while $SDL_EV->poll; |
536 | for CFClient::SDL_PollEvent; |
535 | |
537 | |
536 | if (%animate_object) { |
538 | if (%animate_object) { |
537 | $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; |
539 | $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; |
538 | $want_refresh++; |
540 | $want_refresh++; |
539 | } |
541 | } |
… | |
… | |
569 | my $hp = $stats->{1}; |
571 | my $hp = $stats->{1}; |
570 | my $hp_m = $stats->{2}; |
572 | my $hp_m = $stats->{2}; |
571 | my $sp = $stats->{3}; |
573 | my $sp = $stats->{3}; |
572 | my $sp_m = $stats->{4}; |
574 | my $sp_m = $stats->{4}; |
573 | my $fo = $stats->{18}; |
575 | my $fo = $stats->{18}; |
574 | my $fo_m = 1000; |
576 | my $fo_m = 999; |
575 | my $gr = $stats->{23}; |
577 | my $gr = $stats->{23}; |
576 | my $gr_m = $stats->{24}; |
578 | my $gr_m = $stats->{24}; |
577 | |
579 | |
578 | #d# warn "DATA $hp $hp_m $sp $sp_m $fo $fo_m $gr $gr_m\n"; |
580 | #d# warn "DATA $hp $hp_m $sp $sp_m $fo $fo_m $gr $gr_m\n"; |
579 | $GAUGES->{hp}->set_value ($hp, $hp_m); |
581 | $GAUGES->{hp} ->set_value ($hp, $hp_m); |
580 | $GAUGES->{mana}->set_value ($sp, $sp_m); |
582 | $GAUGES->{mana} ->set_value ($sp, $sp_m); |
581 | $GAUGES->{food}->set_value ($fo, $fo_m); |
583 | $GAUGES->{food} ->set_value ($fo, $fo_m); |
582 | $GAUGES->{grace}->set_value ($gr, $gr_m); |
584 | $GAUGES->{grace}->set_value ($gr, $gr_m); |
583 | } |
585 | } |
584 | |
586 | |
585 | sub conn::user_send { |
587 | sub conn::user_send { |
586 | my ($self, $command) = @_; |
588 | my ($self, $command) = @_; |
… | |
… | |
612 | |
614 | |
613 | my ($hash, $x, $y, $w, $h) = @$map_info; |
615 | my ($hash, $x, $y, $w, $h) = @$map_info; |
614 | |
616 | |
615 | my $data = $MAP->get_rect ($x, $y, $w, $h); |
617 | my $data = $MAP->get_rect ($x, $y, $w, $h); |
616 | $MAPCACHE->put ($hash => Compress::LZF::compress $data); |
618 | $MAPCACHE->put ($hash => Compress::LZF::compress $data); |
617 | |
|
|
618 | warn sprintf "SAVEmap[%s] length %d\n", $hash, length $data;#d# |
619 | #warn sprintf "SAVEmap[%s] length %d\n", $hash, length $data;#d# |
619 | |
|
|
620 | } |
620 | } |
621 | |
621 | |
622 | sub conn::map_clear { |
622 | sub conn::map_clear { |
623 | my ($self) = @_; |
623 | my ($self) = @_; |
624 | |
624 | |
625 | $self->flush_map; |
625 | $self->flush_map; |
626 | delete $self->{neigh}; |
626 | delete $self->{neigh_map}; |
627 | |
627 | |
628 | $MAP->clear; |
628 | $MAP->clear; |
629 | } |
629 | } |
630 | |
630 | |
631 | |
631 | |
632 | sub conn::load_map($$$) { |
632 | sub conn::load_map($$$) { |
633 | my ($self, $hash, $x, $y) = @_; |
633 | my ($self, $hash, $x, $y) = @_; |
634 | |
634 | |
635 | if (defined (my $data = $MAPCACHE->get ($hash))) { |
635 | if (defined (my $data = $MAPCACHE->get ($hash))) { |
636 | $data = Compress::LZF::decompress $data; |
636 | $data = Compress::LZF::decompress $data; |
637 | warn sprintf "LOADmap[%s,%d,%d] length %d\n", $hash, $x, $y, length $data;#d# |
637 | #warn sprintf "LOADmap[%s,%d,%d] length %d\n", $hash, $x, $y, length $data;#d# |
638 | for my $id ($MAP->set_rect ($x, $y, $data)) { |
638 | for my $id ($MAP->set_rect ($x, $y, $data)) { |
639 | my $data = $TILECACHE->get ($id) |
639 | my $data = $TILECACHE->get ($id) |
640 | or next; |
640 | or next; |
641 | |
641 | |
642 | $self->set_texture ($id => $data); |
642 | $self->set_texture ($id => $data); |
643 | } |
643 | } |
644 | } |
644 | } |
645 | } |
645 | } |
646 | |
646 | |
|
|
647 | # this method does a "flood fill" into every tile direction |
|
|
648 | # it assumes that tiles are arranged in a rectangular grid, |
|
|
649 | # i.e. a map is the same as the left of the right map etc. |
|
|
650 | # failure to comply are harmless and result in display errors |
|
|
651 | # at worst. |
647 | sub conn::flood_fill { |
652 | sub conn::flood_fill { |
648 | my ($self, $path, $hash, $flags, $x0, $y0, $x1, $y1) = @_; |
653 | my ($self, $gx, $gy, $path, $hash, $flags) = @_; |
649 | |
654 | |
650 | # the server does not allow map paths > 6 |
655 | # the server does not allow map paths > 6 |
651 | return if 6 <= length $path; |
656 | return if 6 <= length $path; |
652 | |
657 | |
653 | for my $tile (1..4) { |
658 | my ($x0, $y0, $x1, $y1) = @{$self->{neigh_rect}}; |
654 | next if $self->{neigh}{$hash}[$tile]; |
659 | |
|
|
660 | for ( |
|
|
661 | [1, 0, -1], |
|
|
662 | [2, 1, 0], |
|
|
663 | [3, 0, 1], |
|
|
664 | [4, -1, 0], |
|
|
665 | ) { |
|
|
666 | my ($tile, $dx, $dy) = @$_; |
|
|
667 | |
|
|
668 | my $gx = $gx + $dx; |
|
|
669 | my $gy = $gy + $dy; |
|
|
670 | |
655 | next unless $flags & (1 << ($tile - 1)); |
671 | next unless $flags & (1 << ($tile - 1)); |
|
|
672 | next if $self->{neigh_grid}{$gx, $gy}++; |
656 | |
673 | |
657 | my $neigh = $self->{neigh}{$hash} ||= []; |
674 | my $neigh = $self->{neigh_map}{$hash} ||= []; |
658 | |
675 | if (my $info = $neigh->[$tile]) { |
659 | $self->send_mapinfo ("spatial $path$tile", sub { |
|
|
660 | my ($mode, $flags, $x, $y, $w, $h, $hash) = @_; |
676 | my ($flags, $x, $y, $w, $h, $hash) = @$info; |
661 | |
677 | |
662 | #warn "map<$path>_$tile=<$mode,$x,$y,$w,$h,$hash>\n";#d# |
|
|
663 | return if $mode ne "spatial"; |
|
|
664 | |
|
|
665 | $x += $MAP->ox; |
|
|
666 | $y += $MAP->oy; |
|
|
667 | |
|
|
668 | $self->load_map ($hash, $x, $y) |
|
|
669 | unless $self->{neigh}{$hash}[5]++;#d# |
|
|
670 | |
|
|
671 | $neigh->[$tile] = [$x, $y, $w, $h]; |
|
|
672 | |
|
|
673 | $self->flood_fill ("$path$tile", $hash, $flags, $x0, $y0, $x1, $y1) |
678 | $self->flood_fill ($gx, $gy, "$path$tile", $hash, $flags) |
674 | if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1; |
679 | if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1; |
|
|
680 | |
|
|
681 | } else { |
|
|
682 | $self->send_mapinfo ("spatial $path$tile", sub { |
|
|
683 | my ($mode, $flags, $x, $y, $w, $h, $hash) = @_; |
|
|
684 | |
|
|
685 | return if $mode ne "spatial"; |
|
|
686 | |
|
|
687 | $x += $MAP->ox; |
|
|
688 | $y += $MAP->oy; |
|
|
689 | |
|
|
690 | $self->load_map ($hash, $x, $y) |
|
|
691 | unless $self->{neigh_map}{$hash}[5]++;#d# |
|
|
692 | |
|
|
693 | $neigh->[$tile] = [$flags, $x, $y, $w, $h, $hash]; |
|
|
694 | |
|
|
695 | $self->flood_fill ($gx, $gy, "$path$tile", $hash, $flags) |
|
|
696 | if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1; |
|
|
697 | }); |
675 | }); |
698 | } |
676 | } |
699 | } |
677 | } |
700 | } |
678 | |
701 | |
679 | sub conn::map_change { |
702 | sub conn::map_change { |
680 | my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_; |
703 | my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_; |
… | |
… | |
683 | |
706 | |
684 | my ($ox, $oy) = ($::MAP->ox, $::MAP->oy); |
707 | my ($ox, $oy) = ($::MAP->ox, $::MAP->oy); |
685 | |
708 | |
686 | my $mapmapw = 250; |
709 | my $mapmapw = 250; |
687 | my $mapmaph = 250; |
710 | my $mapmaph = 250; |
|
|
711 | |
|
|
712 | $self->{neigh_rect} = [ |
|
|
713 | $ox - $mapmapw * 0.5, $oy - $mapmapw * 0.5, |
|
|
714 | $ox + $mapmapw * 0.5 + $w, $oy + $mapmapw * 0.5 + $h, |
|
|
715 | ]; |
688 | |
716 | |
|
|
717 | delete $self->{neigh_grid}; |
689 | $self->flood_fill ("", $hash, $flags, |
718 | $self->flood_fill (0, 0, "", $hash, $flags); |
690 | $ox - $mapmapw * 0.5, $oy - $mapmapw * 0.5, |
|
|
691 | $ox + $mapmapw * 0.5, $oy + $mapmapw * 0.5); |
|
|
692 | |
719 | |
693 | $x += $ox; |
720 | $x += $ox; |
694 | $y += $oy; |
721 | $y += $oy; |
695 | |
722 | |
696 | $self->{map_info} = [$hash, $x, $y, $w, $h]; |
723 | $self->{map_info} = [$hash, $x, $y, $w, $h]; |
… | |
… | |
756 | } |
783 | } |
757 | |
784 | |
758 | sub conn::sound_play { |
785 | sub conn::sound_play { |
759 | my ($self, $x, $y, $soundnum, $type) = @_; |
786 | my ($self, $x, $y, $soundnum, $type) = @_; |
760 | |
787 | |
|
|
788 | $SDL_MIXER |
|
|
789 | or return; |
|
|
790 | |
761 | my $chunk = $AUDIO_CHUNKS{$SOUNDS[$soundnum]} |
791 | my $chunk = $AUDIO_CHUNKS{$SOUNDS[$soundnum]} |
762 | or return; |
792 | or return; |
763 | |
793 | |
764 | $SDL_MIXER->play_channel (-1, $chunk); |
794 | $chunk->play; |
765 | warn "sound $x,$y,$soundnum,$type\n";#d# |
795 | # warn "sound $x,$y,$soundnum,$type\n";#d# |
766 | } |
796 | } |
767 | |
797 | |
768 | sub conn::query { |
798 | sub conn::query { |
769 | my ($self, $flags, $prompt) = @_; |
799 | my ($self, $flags, $prompt) = @_; |
770 | |
800 | |
771 | #TODO |
801 | #TODO, display dialog with relevant information |
772 | warn "<<<<QUERY:$flags:$prompt>>>\n";#d# |
802 | warn "<<<<QUERY:$flags:$prompt>>>\n";#d# |
773 | } |
803 | } |
774 | |
804 | |
775 | sub conn::drawinfo { |
805 | sub conn::drawinfo { |
776 | my ($self, $color, $text) = @_; |
806 | my ($self, $color, $text) = @_; |
… | |
… | |
792 | ); |
822 | ); |
793 | |
823 | |
794 | $LOGVIEW->add_paragraph ($color[$color], $text); |
824 | $LOGVIEW->add_paragraph ($color[$color], $text); |
795 | } |
825 | } |
796 | |
826 | |
|
|
827 | sub conn::spell_add { |
|
|
828 | my ($self, $spell) = @_; |
|
|
829 | |
|
|
830 | $MAPWIDGET->add_command ("invoke $spell->{name}", $spell->{message}, sub { |
|
|
831 | }); |
|
|
832 | $MAPWIDGET->add_command ("cast $spell->{name}", $spell->{message}, sub { |
|
|
833 | }); |
|
|
834 | } |
|
|
835 | |
|
|
836 | sub conn::spell_delete { |
|
|
837 | my ($self, $spell) = @_; |
|
|
838 | } |
|
|
839 | |
|
|
840 | sub conn::addme_success { |
|
|
841 | my ($self) = @_; |
|
|
842 | |
|
|
843 | for my $skill (values %{$self->{skill_info}}) { |
|
|
844 | $MAPWIDGET->add_command ("ready_skill $skill", "", sub { |
|
|
845 | }); |
|
|
846 | $MAPWIDGET->add_command ("use_skill $skill", "", sub { |
|
|
847 | }); |
|
|
848 | } |
|
|
849 | } |
|
|
850 | |
797 | %SDL_CB = ( |
851 | %SDL_CB = ( |
798 | SDL_QUIT() => sub { |
852 | CFClient::SDL_QUIT => sub { |
799 | Event::unloop -1; |
853 | Event::unloop -1; |
800 | }, |
854 | }, |
801 | SDL_VIDEORESIZE() => sub { |
855 | CFClient::SDL_VIDEORESIZE => sub { |
802 | }, |
856 | }, |
803 | SDL_VIDEOEXPOSE() => sub { |
857 | CFClient::SDL_VIDEOEXPOSE => sub { |
804 | refresh; |
858 | refresh; |
805 | }, |
859 | }, |
806 | SDL_KEYDOWN() => sub { |
860 | CFClient::SDL_KEYDOWN => sub { |
807 | if ($SDL_EV->key_mod & KMOD_ALT && $SDL_EV->key_sym == SDLK_RETURN) { |
861 | if ($_[0]{mod} & CFClient::KMOD_ALT && $_[0]{sym} == 13) { |
808 | # alt-enter |
862 | # alt-enter |
809 | video_shutdown; |
863 | video_shutdown; |
810 | $CFG->{fullscreen} = !$CFG->{fullscreen}; |
864 | $CFG->{fullscreen} = !$CFG->{fullscreen}; |
811 | video_init; |
865 | video_init; |
812 | } else { |
866 | } else { |
813 | CFClient::UI::feed_sdl_key_down_event ($SDL_EV); |
867 | CFClient::UI::feed_sdl_key_down_event ($_[0]); |
814 | } |
868 | } |
815 | }, |
869 | }, |
816 | SDL_KEYUP() => sub { |
870 | CFClient::SDL_KEYUP => sub { |
817 | CFClient::UI::feed_sdl_key_up_event ($SDL_EV); |
871 | CFClient::UI::feed_sdl_key_up_event ($_[0]); |
818 | }, |
872 | }, |
819 | SDL_MOUSEMOTION() => sub { |
873 | CFClient::SDL_MOUSEMOTION => sub { |
820 | CFClient::UI::feed_sdl_motion_event ($SDL_EV); |
874 | CFClient::UI::feed_sdl_motion_event ($_[0]); |
821 | }, |
875 | }, |
822 | SDL_MOUSEBUTTONDOWN() => sub { |
876 | CFClient::SDL_MOUSEBUTTONDOWN => sub { |
823 | CFClient::UI::feed_sdl_button_down_event ($SDL_EV); |
877 | CFClient::UI::feed_sdl_button_down_event ($_[0]); |
824 | }, |
878 | }, |
825 | SDL_MOUSEBUTTONUP() => sub { |
879 | CFClient::SDL_MOUSEBUTTONUP => sub { |
826 | CFClient::UI::feed_sdl_button_up_event ($SDL_EV); |
880 | CFClient::UI::feed_sdl_button_up_event ($_[0]); |
827 | }, |
881 | }, |
828 | SDL_ACTIVEEVENT() => sub { |
882 | CFClient::SDL_ACTIVEEVENT => sub { |
829 | # printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d# |
883 | # printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d# |
830 | }, |
884 | }, |
831 | ); |
885 | ); |
832 | |
886 | |
833 | ############################################################################# |
887 | ############################################################################# |
… | |
… | |
846 | fullscreen => 0, |
900 | fullscreen => 0, |
847 | fast => 0, |
901 | fast => 0, |
848 | fow_enable => 1, |
902 | fow_enable => 1, |
849 | fow_intensity => 0.45, |
903 | fow_intensity => 0.45, |
850 | fow_smooth => 0, |
904 | fow_smooth => 0, |
|
|
905 | gui_fontsize => 1, |
851 | log_fontsize => 14, |
906 | log_fontsize => 14, |
852 | mapsize => 100, |
907 | mapsize => 100, |
853 | host => "crossfire.schmorp.de", |
908 | host => "crossfire.schmorp.de", |
854 | say_command => 'say', |
909 | say_command => 'say', |
|
|
910 | audio_enable => 1, |
|
|
911 | bgm_enable => 1, |
|
|
912 | bgm_volume => 0.25, |
855 | ); |
913 | ); |
856 | |
914 | |
857 | while (my ($k, $v) = each %DEF_CFG) { |
915 | while (my ($k, $v) = each %DEF_CFG) { |
858 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
916 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
859 | } |
917 | } |
860 | |
918 | |
861 | sdl_init; |
919 | sdl_init; |
862 | |
920 | |
863 | @SDL_MODES = reverse |
921 | @SDL_MODES = reverse |
864 | grep $_->[0] >= 640 && $_->[1] >= 480, |
922 | grep $_->[0] >= 640 && $_->[1] >= 480, |
865 | map [SDL::RectW ($_), SDL::RectH ($_)], |
923 | CFClient::SDL_ListModes; |
866 | @{ SDL::ListModes 0, SDL_FULLSCREEN | SDL_HWSURFACE | SDL_OPENGL }; |
|
|
867 | |
924 | |
868 | @SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; |
925 | @SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; |
869 | |
926 | |
870 | $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES; |
927 | $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES; |
871 | |
928 | |
… | |
… | |
879 | video_init; |
936 | video_init; |
880 | audio_init; |
937 | audio_init; |
881 | |
938 | |
882 | Event::loop; |
939 | Event::loop; |
883 | |
940 | |
884 | END { SDL::Quit } |
941 | END { CFClient::SDL_Quit } |
885 | |
942 | |
886 | |
943 | |