… | |
… | |
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 | use SDL::OpenGL; |
|
|
14 | |
|
|
15 | use Crossfire; |
9 | use Crossfire; |
16 | use Crossfire::Protocol; |
10 | use Crossfire::Protocol; |
17 | |
11 | |
18 | use Compress::LZF; |
12 | use Compress::LZF; |
19 | |
13 | |
20 | use CFClient; |
14 | use CFClient; |
21 | use CFClient::UI; |
15 | use CFClient::UI; |
|
|
16 | use CFClient::MapWidget; |
22 | |
17 | |
23 | our $VERSION = '0.1'; |
18 | our $VERSION = '0.1'; |
24 | |
19 | |
25 | my $MAX_FPS = 60; |
20 | my $MAX_FPS = 60; |
26 | my $MIN_FPS = 5; # unused as of yet |
21 | my $MIN_FPS = 5; # unused as of yet |
… | |
… | |
49 | our $BUTTONBAR; |
44 | our $BUTTONBAR; |
50 | our $LOGVIEW; |
45 | our $LOGVIEW; |
51 | our $CONSOLE; |
46 | our $CONSOLE; |
52 | our $METASERVER; |
47 | our $METASERVER; |
53 | |
48 | |
|
|
49 | our $GAUGES; |
|
|
50 | |
54 | our $SDL_ACTIVE; |
51 | our $SDL_ACTIVE; |
55 | our $SDL_EV; |
|
|
56 | our %SDL_CB; |
52 | our %SDL_CB; |
|
|
53 | |
|
|
54 | our $SDL_MIXER; |
|
|
55 | our @SOUNDS; # event => file mapping |
|
|
56 | our %AUDIO_CHUNKS; # audio files |
57 | |
57 | |
58 | our $ALT_ENTER_MESSAGE; |
58 | our $ALT_ENTER_MESSAGE; |
59 | our $STATUS_LINE; |
59 | our $STATUS_LINE; |
60 | our $DEBUG_STATUS; |
60 | our $DEBUG_STATUS; |
61 | |
61 | |
62 | sub status { |
62 | sub status { |
63 | $STATUS_LINE->set_text ($_[0]); |
63 | $STATUS_LINE->set_text ($_[0]); |
64 | my ($w, $h) = $STATUS_LINE->size_request; |
|
|
65 | $STATUS_LINE->size_allocate (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $h, $w, $h); |
64 | $STATUS_LINE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $STATUS_LINE->{h}); |
66 | } |
65 | } |
67 | |
66 | |
68 | sub debug { |
67 | sub debug { |
69 | $DEBUG_STATUS->set_text ($_[0]); |
68 | $DEBUG_STATUS->set_text ($_[0]); |
70 | my ($w, $h) = $DEBUG_STATUS->size_request; |
69 | $DEBUG_STATUS->move ($WIDTH - $DEBUG_STATUS->{w}, 0, $DEBUG_STATUS->{w}, $DEBUG_STATUS->{h}); |
71 | $DEBUG_STATUS->size_allocate ($WIDTH - $w, 0, $w, $h); |
|
|
72 | } |
70 | } |
73 | |
71 | |
74 | sub start_game { |
72 | sub start_game { |
75 | status "logging in..."; |
73 | status "logging in..."; |
76 | |
74 | |
… | |
… | |
101 | } |
99 | } |
102 | |
100 | |
103 | sub client_setup { |
101 | sub client_setup { |
104 | my $dialog = new CFClient::UI::FancyFrame |
102 | my $dialog = new CFClient::UI::FancyFrame |
105 | child => (my $vbox = new CFClient::UI::VBox); |
103 | child => (my $vbox = new CFClient::UI::VBox); |
106 | $vbox->add (new CFClient::UI::Label align => 0, text => "Client Setup"); |
104 | $vbox->add (new CFClient::UI::Label valign => 0, align => 0, text => "Client Setup"); |
107 | $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); |
105 | $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); |
108 | |
106 | |
109 | $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"); |
110 | $table->add (1, 0, my $hbox = new CFClient::UI::HBox); |
108 | $table->add (1, 0, my $hbox = new CFClient::UI::HBox); |
111 | |
109 | |
112 | $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]); |
113 | $hbox->add (my $mode_label = new CFClient::UI::Label height => $FONTSIZE * 0.8); |
111 | $hbox->add (my $mode_label = new CFClient::UI::Label valign => 0, height => 0.8); |
114 | |
112 | |
115 | $mode_slider->connect (changed => sub { |
113 | $mode_slider->connect (changed => sub { |
116 | my ($self, $value) = @_; |
114 | my ($self, $value) = @_; |
117 | |
115 | |
118 | $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value; |
116 | $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value; |
119 | $mode_label->set_text (sprintf "%dx%d", @{$SDL_MODES[$value]}); |
117 | $mode_label->set_text (sprintf "%dx%d", @{$SDL_MODES[$value]}); |
120 | }); |
118 | }); |
121 | $mode_slider->emit (changed => $mode_slider->{range}[0]); |
119 | $mode_slider->emit (changed => $mode_slider->{range}[0]); |
122 | |
120 | |
123 | $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"); |
124 | $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 { |
125 | my ($self, $value) = @_; |
123 | my ($self, $value) = @_; |
126 | $CFG->{fullscreen} = $value; |
124 | $CFG->{fullscreen} = $value; |
127 | }); |
125 | }); |
128 | |
126 | |
129 | $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"); |
130 | $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 { |
131 | my ($self, $value) = @_; |
129 | my ($self, $value) = @_; |
132 | $CFG->{fast} = $value; |
130 | $CFG->{fast} = $value; |
133 | }); |
131 | }); |
134 | |
132 | |
135 | $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"); |
136 | $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 { |
137 | my ($self, $value) = @_; |
135 | my ($self, $value) = @_; |
138 | $CFG->{fow_enable} = $value; |
136 | $CFG->{fow_enable} = $value; |
139 | }); |
137 | }); |
140 | |
138 | |
141 | $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"); |
142 | $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 { |
143 | my ($self, $value) = @_; |
141 | my ($self, $value) = @_; |
144 | $CFG->{fow_intensity} = $value; |
142 | $CFG->{fow_intensity} = $value; |
145 | }); |
143 | }); |
146 | |
144 | |
147 | $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"); |
148 | $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 { |
149 | my ($self, $value) = @_; |
147 | my ($self, $value) = @_; |
150 | $CFG->{fow_smooth} = $value; |
148 | $CFG->{fow_smooth} = $value; |
|
|
149 | status "Fog of War smoothing requires OpenGL 1.2 or higher" if $CFClient::GL_VERSION < 1.2; |
151 | }); |
150 | }); |
152 | |
151 | |
153 | $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"); |
154 | $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 { |
155 | my ($self, $value) = @_; |
|
|
156 | $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = int $value); |
160 | $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = 0.1 * int $_[1] * 10); |
157 | }); |
161 | }); |
158 | |
162 | |
159 | $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 { |
160 | destroy_screen (); |
164 | video_shutdown (); |
161 | init_screen (); |
165 | video_init (); |
|
|
166 | }); |
|
|
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::Mix_VolumeMusic ($_[1]); |
|
|
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 (); |
162 | }); |
189 | }); |
163 | |
190 | |
164 | $dialog |
191 | $dialog |
165 | } |
192 | } |
166 | |
193 | |
… | |
… | |
230 | $HOST->set_text ($CFG->{host} = $host); |
257 | $HOST->set_text ($CFG->{host} = $host); |
231 | }), |
258 | }), |
232 | (new CFClient::UI::Empty expand => 1), |
259 | (new CFClient::UI::Empty expand => 1), |
233 | ]); |
260 | ]); |
234 | |
261 | |
235 | $table->add ($_ + 1, $y, new CFClient::UI::Label align => $align[$_], text => $m->[$_], fontsize => $FONTSIZE * 0.8) |
262 | $table->add ($_ + 1, $y, new CFClient::UI::Label align => $align[$_], text => $m->[$_], fontsize => 0.8) |
236 | for 0 .. $#$m; |
263 | for 0 .. $#$m; |
237 | } |
264 | } |
238 | } |
265 | } |
239 | }); |
266 | }); |
240 | } |
267 | } |
241 | |
268 | |
242 | sub server_setup { |
269 | sub server_setup { |
243 | my $dialog = new CFClient::UI::FancyFrame |
270 | my $dialog = new CFClient::UI::FancyFrame |
244 | child => (my $vbox = new CFClient::UI::VBox); |
271 | child => (my $vbox = new CFClient::UI::VBox); |
245 | |
272 | |
246 | $vbox->add (new CFClient::UI::Label align => 0, text => "Server Setup"); |
273 | $vbox->add (new CFClient::UI::Label valign => 0, align => 0, text => "Server Setup"); |
247 | $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); |
274 | $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); |
248 | $table->add (0, 2, new CFClient::UI::Label align => 1, text => "Host:Port"); |
275 | $table->add (0, 2, new CFClient::UI::Label valign => 0, align => 1, text => "Host:Port"); |
249 | |
276 | |
250 | { |
277 | { |
251 | $table->add (1, 2, my $vbox = new CFClient::UI::VBox); |
278 | $table->add (1, 2, my $vbox = new CFClient::UI::VBox); |
252 | |
279 | |
253 | $vbox->add (my $HOST = new CFClient::UI::Entry text => $CFG->{host}, connect_changed => sub { |
280 | $vbox->add (my $HOST = new CFClient::UI::Entry expand => 1, text => $CFG->{host}, connect_changed => sub { |
254 | my ($self, $value) = @_; |
281 | my ($self, $value) = @_; |
255 | $CFG->{host} = $value; |
282 | $CFG->{host} = $value; |
256 | }); |
283 | }); |
257 | |
284 | |
258 | $METASERVER = metaserver_dialog; |
285 | $METASERVER = metaserver_dialog; |
259 | |
286 | |
260 | $vbox->add (new CFClient::UI::Flopper text => "Metaserver", other => $METASERVER, connect_open => sub { |
287 | $vbox->add (new CFClient::UI::Flopper expand => 1, text => "Metaserver", other => $METASERVER, connect_open => sub { |
261 | update_metaserver $HOST; |
288 | update_metaserver $HOST; |
262 | }); |
289 | }); |
263 | } |
290 | } |
264 | |
291 | |
265 | $table->add (0, 4, new CFClient::UI::Label align => 1, text => "Username"); |
292 | $table->add (0, 4, new CFClient::UI::Label valign => 0, align => 1, text => "Username"); |
266 | $table->add (1, 4, new CFClient::UI::Entry text => $CFG->{user}, connect_changed => sub { |
293 | $table->add (1, 4, new CFClient::UI::Entry text => $CFG->{user}, connect_changed => sub { |
267 | my ($self, $value) = @_; |
294 | my ($self, $value) = @_; |
268 | $CFG->{user} = $value; |
295 | $CFG->{user} = $value; |
269 | }); |
296 | }); |
270 | |
297 | |
271 | $table->add (0, 5, new CFClient::UI::Label align => 1, text => "Password"); |
298 | $table->add (0, 5, new CFClient::UI::Label valign => 0, align => 1, text => "Password"); |
272 | $table->add (1, 5, new CFClient::UI::Entry text => $CFG->{password}, hidden => 1, connect_changed => sub { |
299 | $table->add (1, 5, new CFClient::UI::Entry text => $CFG->{password}, hidden => 1, connect_changed => sub { |
273 | my ($self, $value) = @_; |
300 | my ($self, $value) = @_; |
274 | $CFG->{password} = $value; |
301 | $CFG->{password} = $value; |
275 | }); |
302 | }); |
276 | |
303 | |
277 | $table->add (0, 6, new CFClient::UI::Label align => 1, text => "Def. say cmd"); |
304 | $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "Def. say cmd"); |
278 | $table->add (1, 6, my $saycmd = new CFClient::UI::Entry text => $CFG->{say_command}, connect_changed => sub { |
305 | $table->add (1, 6, my $saycmd = new CFClient::UI::Entry text => $CFG->{say_command}, connect_changed => sub { |
279 | my ($self, $value) = @_; |
306 | my ($self, $value) = @_; |
280 | $CFG->{say_command} = $value; |
307 | $CFG->{say_command} = $value; |
281 | }); |
308 | }); |
282 | |
309 | |
283 | $table->add (0, 7, new CFClient::UI::Label align => 1, text => "Map Size"); |
310 | $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size"); |
284 | $table->add (1, 7, new CFClient::UI::Slider |
311 | $table->add (1, 7, new CFClient::UI::Slider |
285 | req_w => 100, |
312 | req_w => 100, |
286 | range => [$CFG->{mapsize}, 10, 100 + 1, 1], |
313 | range => [$CFG->{mapsize}, 10, 100 + 1, 1], |
287 | connect_changed => sub { |
314 | connect_changed => sub { |
288 | my ($self, $value) = @_; |
315 | my ($self, $value) = @_; |
… | |
… | |
300 | |
327 | |
301 | sub message_window { |
328 | sub message_window { |
302 | my $window = new CFClient::UI::FancyFrame |
329 | my $window = new CFClient::UI::FancyFrame |
303 | border_bg => [1, 1, 1, 0.5], |
330 | border_bg => [1, 1, 1, 0.5], |
304 | bg => [0.3, 0.3, 0.3, 0.8], |
331 | bg => [0.3, 0.3, 0.3, 0.8], |
305 | user_w => $::WIDTH/4, |
332 | user_w => int $::WIDTH / 3, |
306 | user_h => $::HEIGHT, |
333 | user_h => int $::HEIGHT / 5, |
307 | child => (my $vbox = new CFClient::UI::VBox); |
334 | child => (my $vbox = new CFClient::UI::VBox); |
308 | |
335 | |
309 | $vbox->add ($LOGVIEW = new CFClient::UI::TextView |
336 | $vbox->add ($LOGVIEW = new CFClient::UI::TextView |
310 | expand => 1, |
337 | expand => 1, |
311 | fontsize => $::CFG->{log_fontsize}, |
338 | fontsize => $::CFG->{log_fontsize}, |
312 | ); |
339 | ); |
313 | |
340 | |
314 | $vbox->add (my $input = new CFClient::UI::LineEntry |
341 | $vbox->add (my $input = new CFClient::UI::Entry |
315 | connect_focus_in => sub { |
342 | connect_focus_in => sub { |
316 | my ($input, $prev_focus) = @_; |
343 | my ($input, $prev_focus) = @_; |
317 | |
344 | |
318 | delete $input->{refocus_map}; |
345 | delete $input->{refocus_map}; |
319 | |
346 | |
… | |
… | |
325 | connect_activate => sub { |
352 | connect_activate => sub { |
326 | my ($input, $text) = @_; |
353 | my ($input, $text) = @_; |
327 | $input->set_text (''); |
354 | $input->set_text (''); |
328 | |
355 | |
329 | if ($text =~ /^\/(.*)/) { |
356 | if ($text =~ /^\/(.*)/) { |
330 | $::CONN->user_send ("command $1"); |
357 | $::CONN->user_send ($1); |
331 | } else { |
358 | } else { |
332 | my $say_cmd = $::CFG->{say_command} || 'say'; |
359 | my $say_cmd = $::CFG->{say_command} || 'say'; |
333 | $::CONN->user_send ("command $say_cmd $text"); |
360 | $::CONN->user_send ("$say_cmd $text"); |
334 | } |
361 | } |
335 | if ($input->{refocus_map}) { |
362 | if ($input->{refocus_map}) { |
336 | delete $input->{refocus_map}; |
363 | delete $input->{refocus_map}; |
337 | $MAPWIDGET->focus_in |
364 | $MAPWIDGET->focus_in |
338 | } |
365 | } |
… | |
… | |
349 | |
376 | |
350 | $window |
377 | $window |
351 | } |
378 | } |
352 | |
379 | |
353 | sub sdl_init { |
380 | sub sdl_init { |
354 | #SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE |
381 | CFClient::SDL_Init |
355 | SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO |
|
|
356 | and die "SDL::Init failed!\n"; |
382 | and die "SDL::Init failed!\n"; |
357 | } |
383 | } |
358 | |
384 | |
359 | sub init_screen { |
385 | sub video_init { |
360 | sdl_init; |
386 | sdl_init; |
361 | |
387 | |
362 | ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; |
388 | ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; |
363 | $FULLSCREEN = $CFG->{fullscreen}; |
389 | $FULLSCREEN = $CFG->{fullscreen}; |
364 | $FAST = $CFG->{fast}; |
390 | $FAST = $CFG->{fast}; |
365 | |
391 | |
366 | SDL::GLSetAttribute SDL_GL_RED_SIZE, 5; |
392 | CFClient::SDL_SetVideoMode $WIDTH, $HEIGHT, $FULLSCREEN |
367 | SDL::GLSetAttribute SDL_GL_GREEN_SIZE, 5; |
|
|
368 | SDL::GLSetAttribute SDL_GL_BLUE_SIZE, 5; |
|
|
369 | SDL::GLSetAttribute SDL_GL_ALPHA_SIZE, 1; |
|
|
370 | |
|
|
371 | SDL::GLSetAttribute SDL_GL_ACCUM_RED_SIZE, 0; |
|
|
372 | SDL::GLSetAttribute SDL_GL_ACCUM_GREEN_SIZE, 0; |
|
|
373 | SDL::GLSetAttribute SDL_GL_ACCUM_BLUE_SIZE, 0; |
|
|
374 | SDL::GLSetAttribute SDL_GL_ACCUM_ALPHA_SIZE, 0; |
|
|
375 | |
|
|
376 | SDL::GLSetAttribute SDL_GL_DOUBLEBUFFER, 1; |
|
|
377 | SDL::GLSetAttribute SDL_GL_BUFFER_SIZE, 15; |
|
|
378 | SDL::GLSetAttribute SDL_GL_DEPTH_SIZE, 0; |
|
|
379 | |
|
|
380 | SDL::SetVideoMode $WIDTH, $HEIGHT, 0, |
|
|
381 | SDL_HWSURFACE | SDL_ANYFORMAT | SDL_OPENGL | SDL_DOUBLEBUF |
|
|
382 | | ($FULLSCREEN ? SDL_FULLSCREEN : 0) |
|
|
383 | or die "SDL::SetVideoMode failed!\n"; |
393 | or die "SDL_SetVideoMode failed!\n"; |
384 | |
|
|
385 | SDL::WMSetCaption "Crossfire+ Client", "Crossfire+"; |
|
|
386 | |
|
|
387 | $SDL_EV = new SDL::Event; |
|
|
388 | $SDL_EV->set_unicode (1); |
|
|
389 | |
394 | |
390 | $SDL_ACTIVE = 1; |
395 | $SDL_ACTIVE = 1; |
391 | |
396 | |
392 | $LAST_REFRESH = time - 0.01; |
397 | $LAST_REFRESH = time - 0.01; |
393 | |
398 | |
394 | CFClient::gl_init; |
399 | CFClient::gl_init; |
395 | |
400 | |
396 | $FONTSIZE = int $HEIGHT / 40; |
401 | $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize}; |
397 | |
402 | |
398 | ############################################################################# |
403 | ############################################################################# |
399 | |
404 | |
400 | $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100; |
405 | $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100; |
401 | $CFClient::UI::ROOT->add ($DEBUG_STATUS); |
406 | $DEBUG_STATUS->show; |
402 | |
407 | |
403 | $STATUS_LINE = new CFClient::UI::Label |
408 | $STATUS_LINE = new CFClient::UI::Label |
404 | padding => 0, |
409 | padding => 0, |
405 | y => $HEIGHT * 44 / 45 - $FONTSIZE; |
410 | y => $HEIGHT - $FONTSIZE * 1.8; |
406 | $CFClient::UI::ROOT->add ($STATUS_LINE); |
411 | $STATUS_LINE->show; |
407 | |
412 | |
408 | $ALT_ENTER_MESSAGE = new CFClient::UI::Label |
413 | $ALT_ENTER_MESSAGE = new CFClient::UI::Label |
409 | padding => 0, |
414 | padding => 0, |
410 | y => $HEIGHT * 44 / 45, |
415 | fontsize => 0.8, |
411 | height => $HEIGHT / 45, |
|
|
412 | text => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; |
416 | markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; |
413 | $CFClient::UI::ROOT->add ($ALT_ENTER_MESSAGE); |
417 | $ALT_ENTER_MESSAGE->show; |
|
|
418 | $ALT_ENTER_MESSAGE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h}); |
414 | |
419 | |
415 | $CFClient::UI::ROOT->add ($MAPWIDGET = new CFClient::UI::MapWidget); |
420 | $CFClient::UI::ROOT->add ($MAPWIDGET = new CFClient::MapWidget); |
416 | $MAPWIDGET->focus_in; |
421 | $MAPWIDGET->focus_in; |
417 | $MAPWIDGET->connect (activate_console => sub { |
422 | $MAPWIDGET->connect (activate_console => sub { |
418 | my ($mapwidget, $preset) = @_; |
423 | my ($mapwidget, $preset) = @_; |
419 | |
424 | |
420 | if ($CONSOLE) { |
425 | if ($CONSOLE) { |
… | |
… | |
437 | CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; |
442 | CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; |
438 | status "Configuration Saved"; |
443 | status "Configuration Saved"; |
439 | }); |
444 | }); |
440 | |
445 | |
441 | $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup |
446 | $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup |
442 | } |
|
|
443 | |
447 | |
444 | sub destroy_screen { |
448 | my $tgw = new CFClient::UI::FancyFrame (x => $WIDTH - 300, y => 0); |
|
|
449 | $tgw->add (my $hbox = new CFClient::UI::HBox ()); |
|
|
450 | |
|
|
451 | $hbox->add (my $hg = new CFClient::UI::VGauge (gauge => 'hp')); |
|
|
452 | $hbox->add (my $mg = new CFClient::UI::VGauge (gauge => 'mana')); |
|
|
453 | $hbox->add (my $gg = new CFClient::UI::VGauge (gauge => 'grace')); |
|
|
454 | $hbox->add (my $fg = new CFClient::UI::VGauge (gauge => 'food')); |
|
|
455 | |
|
|
456 | $GAUGES = { food => $fg, mana => $mg, hp => $hg, grace => $gg }; |
|
|
457 | $CFClient::UI::ROOT->add ($tgw); |
|
|
458 | } |
|
|
459 | |
|
|
460 | sub video_shutdown { |
445 | $CFClient::UI::ROOT->{children} = []; |
461 | $CFClient::UI::ROOT->{children} = []; |
446 | undef $SDL_ACTIVE; |
462 | undef $SDL_ACTIVE; |
|
|
463 | } |
|
|
464 | |
|
|
465 | my $bgmusic;#TODO#hack#d# |
|
|
466 | |
|
|
467 | sub audio_init { |
|
|
468 | if ($CFG->{audio_enable}) { |
|
|
469 | if (open my $fh, "<:utf8", CFClient::find_rcfile "sounds/config") { |
|
|
470 | |
|
|
471 | $SDL_MIXER = !CFClient::Mix_OpenAudio; |
|
|
472 | CFClient::Mix_AllocateChannels 8; |
|
|
473 | CFClient::MixMusic::volume $CFG->{bgm_volume}; |
|
|
474 | |
|
|
475 | # TODO: hack, do play loop and mood music |
|
|
476 | if ($CFG->{bgm_enable}) { |
|
|
477 | $bgmusic = new_from_file CFClient::MixMusic CFClient::find_rcfile "music/game3.ogg"; |
|
|
478 | $bgmusic->play; |
|
|
479 | } |
|
|
480 | |
|
|
481 | while (<$fh>) { |
|
|
482 | next if /^\s*#/; |
|
|
483 | next if /^\s*$/; |
|
|
484 | |
|
|
485 | my ($file, $volume, $event) = split /\s+/, $_, 3; |
|
|
486 | |
|
|
487 | push @SOUNDS, "$volume,$file"; |
|
|
488 | |
|
|
489 | $AUDIO_CHUNKS{"$volume,$file"} ||= do { |
|
|
490 | my $chunk = new_from_file CFClient::MixChunk CFClient::find_rcfile "sounds/$file"; |
|
|
491 | $chunk->volume ($volume * 128 / 100); |
|
|
492 | $chunk |
|
|
493 | }; |
|
|
494 | } |
|
|
495 | } else { |
|
|
496 | status "unable to open sound config: $!"; |
|
|
497 | } |
|
|
498 | } |
|
|
499 | } |
|
|
500 | |
|
|
501 | sub audio_shutdown { |
|
|
502 | CFClient::Mix_CloseAudio if $SDL_MIXER; |
447 | undef $SDL_EV; |
503 | undef $SDL_MIXER; |
448 | SDL::Quit; |
504 | @SOUNDS = (); |
|
|
505 | %AUDIO_CHUNKS = (); |
449 | } |
506 | } |
450 | |
507 | |
451 | my %animate_object; |
508 | my %animate_object; |
452 | my $animate_timer; |
509 | my $animate_timer; |
453 | |
510 | |
… | |
… | |
463 | $want_refresh = 0; |
520 | $want_refresh = 0; |
464 | $can_refresh = 0; |
521 | $can_refresh = 0; |
465 | |
522 | |
466 | $CFClient::UI::ROOT->draw; |
523 | $CFClient::UI::ROOT->draw; |
467 | |
524 | |
468 | SDL::GLSwapBuffers; |
525 | CFClient::SDL_GL_SwapBuffers; |
469 | |
526 | |
470 | $LAST_REFRESH = $NOW; |
527 | $LAST_REFRESH = $NOW; |
471 | } |
528 | } |
472 | |
529 | |
473 | my $refresh_watcher = Event->timer (after => 0, hard => 1, interval => 1 / $MAX_FPS, cb => sub { |
530 | my $refresh_watcher = Event->timer (after => 0, hard => 1, interval => 1 / $MAX_FPS, cb => sub { |
474 | $NOW = time; |
531 | $NOW = time; |
475 | |
532 | |
476 | ($SDL_CB{$SDL_EV->type} || sub { warn "unhandled event ", $SDL_EV->type })->() |
533 | ($SDL_CB{$_->{type}} || sub { warn "unhandled event $_->{type}" })->($_) |
477 | while $SDL_EV->poll; |
534 | for CFClient::SDL_PollEvent; |
478 | |
535 | |
479 | if (%animate_object) { |
536 | if (%animate_object) { |
480 | $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; |
537 | $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; |
481 | $want_refresh++; |
538 | $want_refresh++; |
482 | } |
539 | } |
… | |
… | |
502 | delete $animate_object{$widget}; |
559 | delete $animate_object{$widget}; |
503 | } |
560 | } |
504 | |
561 | |
505 | @conn::ISA = Crossfire::Protocol::; |
562 | @conn::ISA = Crossfire::Protocol::; |
506 | |
563 | |
|
|
564 | sub conn::stats_update { |
|
|
565 | my ($self, $stats) = @_; |
|
|
566 | |
|
|
567 | # i love text protocols!!! |
|
|
568 | # FIXME: the stats are somehow weird |
|
|
569 | my $hp = $stats->{1}; |
|
|
570 | my $hp_m = $stats->{2}; |
|
|
571 | my $sp = $stats->{3}; |
|
|
572 | my $sp_m = $stats->{4}; |
|
|
573 | my $fo = $stats->{18}; |
|
|
574 | my $fo_m = 1000; |
|
|
575 | my $gr = $stats->{23}; |
|
|
576 | my $gr_m = $stats->{24}; |
|
|
577 | |
|
|
578 | #d# warn "DATA $hp $hp_m $sp $sp_m $fo $fo_m $gr $gr_m\n"; |
|
|
579 | $GAUGES->{hp}->set_value ($hp, $hp_m); |
|
|
580 | $GAUGES->{mana}->set_value ($sp, $sp_m); |
|
|
581 | $GAUGES->{food}->set_value ($fo, $fo_m); |
|
|
582 | $GAUGES->{grace}->set_value ($gr, $gr_m); |
|
|
583 | } |
|
|
584 | |
507 | sub conn::user_send { |
585 | sub conn::user_send { |
508 | my ($self, $command) = @_; |
586 | my ($self, $command) = @_; |
509 | |
587 | |
510 | $self->send ($command); |
588 | $self->send_command ($command); |
511 | status $command; |
589 | status $command; |
512 | } |
590 | } |
513 | |
591 | |
514 | sub conn::map_scroll { |
592 | sub conn::map_scroll { |
515 | my ($self, $dx, $dy) = @_; |
593 | my ($self, $dx, $dy) = @_; |
… | |
… | |
567 | } |
645 | } |
568 | |
646 | |
569 | sub conn::flood_fill { |
647 | sub conn::flood_fill { |
570 | my ($self, $path, $hash, $flags, $x0, $y0, $x1, $y1) = @_; |
648 | my ($self, $path, $hash, $flags, $x0, $y0, $x1, $y1) = @_; |
571 | |
649 | |
572 | # the server doe snot allow map paths > 6 |
650 | # the server does not allow map paths > 6 |
573 | return if 6 <= length $path; |
651 | return if 6 <= length $path; |
574 | |
652 | |
575 | for my $tile (1..4) { |
653 | for my $tile (1..4) { |
576 | next if $self->{neigh}{$hash}[$tile]; |
654 | next if $self->{neigh}{$hash}[$tile]; |
577 | next unless $flags & (1 << ($tile - 1)); |
655 | next unless $flags & (1 << ($tile - 1)); |
… | |
… | |
579 | my $neigh = $self->{neigh}{$hash} ||= []; |
657 | my $neigh = $self->{neigh}{$hash} ||= []; |
580 | |
658 | |
581 | $self->send_mapinfo ("spatial $path$tile", sub { |
659 | $self->send_mapinfo ("spatial $path$tile", sub { |
582 | my ($mode, $flags, $x, $y, $w, $h, $hash) = @_; |
660 | my ($mode, $flags, $x, $y, $w, $h, $hash) = @_; |
583 | |
661 | |
584 | warn "map<$path>_$tile=<$mode,$x,$y,$w,$h,$hash>\n";#d# |
662 | #warn "map<$path>_$tile=<$mode,$x,$y,$w,$h,$hash>\n";#d# |
585 | return if $mode ne "spatial"; |
663 | return if $mode ne "spatial"; |
586 | |
664 | |
587 | $x += $MAP->ox; |
665 | $x += $MAP->ox; |
588 | $y += $MAP->oy; |
666 | $y += $MAP->oy; |
589 | |
667 | |
590 | $self->load_map ($hash, $x, $y); |
668 | $self->load_map ($hash, $x, $y) |
|
|
669 | unless $self->{neigh}{$hash}[5]++;#d# |
591 | |
670 | |
592 | $neigh->[$tile] = [$x, $y, $w, $h]; |
671 | $neigh->[$tile] = [$x, $y, $w, $h]; |
593 | |
672 | |
594 | $self->flood_fill ("$path$tile", $hash, $flags, $x0, $y0, $x1, $y1) |
673 | $self->flood_fill ("$path$tile", $hash, $flags, $x0, $y0, $x1, $y1) |
595 | if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1; |
674 | if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1; |
… | |
… | |
601 | my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_; |
680 | my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_; |
602 | |
681 | |
603 | $self->flush_map; |
682 | $self->flush_map; |
604 | |
683 | |
605 | my ($ox, $oy) = ($::MAP->ox, $::MAP->oy); |
684 | my ($ox, $oy) = ($::MAP->ox, $::MAP->oy); |
606 | |
|
|
607 | warn "$ox $oy map_info<$flags, $x, $y, $w, $h, $hash>\n";#d# |
|
|
608 | |
685 | |
609 | my $mapmapw = 250; |
686 | my $mapmapw = 250; |
610 | my $mapmaph = 250; |
687 | my $mapmaph = 250; |
611 | |
688 | |
612 | $self->flood_fill ("", $hash, $flags, |
689 | $self->flood_fill ("", $hash, $flags, |
… | |
… | |
676 | |
753 | |
677 | $tex |
754 | $tex |
678 | }; |
755 | }; |
679 | } |
756 | } |
680 | |
757 | |
|
|
758 | sub conn::sound_play { |
|
|
759 | my ($self, $x, $y, $soundnum, $type) = @_; |
|
|
760 | |
|
|
761 | $SDL_MIXER |
|
|
762 | or return; |
|
|
763 | |
|
|
764 | my $chunk = $AUDIO_CHUNKS{$SOUNDS[$soundnum]} |
|
|
765 | or return; |
|
|
766 | |
|
|
767 | $chunk->play; |
|
|
768 | # warn "sound $x,$y,$soundnum,$type\n";#d# |
|
|
769 | } |
|
|
770 | |
681 | sub conn::query { |
771 | sub conn::query { |
682 | my ($self, $flags, $prompt) = @_; |
772 | my ($self, $flags, $prompt) = @_; |
683 | |
773 | |
684 | #TODO |
774 | #TODO, display dialog with relevant information |
685 | warn "<<<<QUERY:$flags:$prompt>>>\n";#d# |
775 | warn "<<<<QUERY:$flags:$prompt>>>\n";#d# |
686 | } |
776 | } |
687 | |
777 | |
688 | sub conn::drawinfo { |
778 | sub conn::drawinfo { |
689 | my ($self, $color, $text) = @_; |
779 | my ($self, $color, $text) = @_; |
… | |
… | |
705 | ); |
795 | ); |
706 | |
796 | |
707 | $LOGVIEW->add_paragraph ($color[$color], $text); |
797 | $LOGVIEW->add_paragraph ($color[$color], $text); |
708 | } |
798 | } |
709 | |
799 | |
|
|
800 | sub conn::spell_add { |
|
|
801 | my ($self, $spell) = @_; |
|
|
802 | |
|
|
803 | $MAPWIDGET->add_command ("invoke $spell->{name}", $spell->{message}, sub { |
|
|
804 | }); |
|
|
805 | $MAPWIDGET->add_command ("cast $spell->{name}", $spell->{message}, sub { |
|
|
806 | }); |
|
|
807 | } |
|
|
808 | |
|
|
809 | sub conn::spell_delete { |
|
|
810 | my ($self, $spell) = @_; |
|
|
811 | } |
|
|
812 | |
|
|
813 | sub conn::addme_success { |
|
|
814 | my ($self) = @_; |
|
|
815 | |
|
|
816 | for my $skill (values %{$self->{skill_info}}) { |
|
|
817 | $MAPWIDGET->add_command ("ready_skill $skill", "", sub { |
|
|
818 | }); |
|
|
819 | $MAPWIDGET->add_command ("use_skill $skill", "", sub { |
|
|
820 | }); |
|
|
821 | } |
|
|
822 | } |
|
|
823 | |
710 | %SDL_CB = ( |
824 | %SDL_CB = ( |
711 | SDL_QUIT() => sub { |
825 | CFClient::SDL_QUIT => sub { |
712 | Event::unloop -1; |
826 | Event::unloop -1; |
713 | }, |
827 | }, |
714 | SDL_VIDEORESIZE() => sub { |
828 | CFClient::SDL_VIDEORESIZE => sub { |
715 | }, |
829 | }, |
716 | SDL_VIDEOEXPOSE() => sub { |
830 | CFClient::SDL_VIDEOEXPOSE => sub { |
717 | refresh; |
831 | refresh; |
718 | }, |
832 | }, |
719 | SDL_KEYDOWN() => sub { |
833 | CFClient::SDL_KEYDOWN => sub { |
720 | if ($SDL_EV->key_mod & KMOD_ALT && $SDL_EV->key_sym == SDLK_RETURN) { |
834 | if ($_[0]{mod} & CFClient::KMOD_ALT && $_[0]{sym} == 13) { |
721 | # alt-enter |
835 | # alt-enter |
722 | destroy_screen; |
836 | video_shutdown; |
723 | $CFG->{fullscreen} = !$CFG->{fullscreen}; |
837 | $CFG->{fullscreen} = !$CFG->{fullscreen}; |
724 | init_screen; |
838 | video_init; |
725 | } else { |
839 | } else { |
726 | CFClient::UI::feed_sdl_key_down_event ($SDL_EV); |
840 | CFClient::UI::feed_sdl_key_down_event ($_[0]); |
727 | } |
841 | } |
728 | }, |
842 | }, |
729 | SDL_KEYUP() => sub { |
843 | CFClient::SDL_KEYUP => sub { |
730 | CFClient::UI::feed_sdl_key_up_event ($SDL_EV); |
844 | CFClient::UI::feed_sdl_key_up_event ($_[0]); |
731 | }, |
845 | }, |
732 | SDL_MOUSEMOTION() => sub { |
846 | CFClient::SDL_MOUSEMOTION => sub { |
733 | CFClient::UI::feed_sdl_motion_event ($SDL_EV); |
847 | CFClient::UI::feed_sdl_motion_event ($_[0]); |
734 | }, |
848 | }, |
735 | SDL_MOUSEBUTTONDOWN() => sub { |
849 | CFClient::SDL_MOUSEBUTTONDOWN => sub { |
736 | CFClient::UI::feed_sdl_button_down_event ($SDL_EV); |
850 | CFClient::UI::feed_sdl_button_down_event ($_[0]); |
737 | }, |
851 | }, |
738 | SDL_MOUSEBUTTONUP() => sub { |
852 | CFClient::SDL_MOUSEBUTTONUP => sub { |
739 | CFClient::UI::feed_sdl_button_up_event ($SDL_EV); |
853 | CFClient::UI::feed_sdl_button_up_event ($_[0]); |
740 | }, |
854 | }, |
741 | SDL_ACTIVEEVENT() => sub { |
855 | CFClient::SDL_ACTIVEEVENT => sub { |
742 | # printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d# |
856 | # printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d# |
743 | }, |
857 | }, |
744 | ); |
858 | ); |
745 | |
859 | |
746 | ############################################################################# |
860 | ############################################################################# |
|
|
861 | |
|
|
862 | $SIG{INT} = $SIG{TERM} = sub { exit }; |
747 | |
863 | |
748 | $TILECACHE = CFClient::db_table "tilecache"; |
864 | $TILECACHE = CFClient::db_table "tilecache"; |
749 | $FACEMAP = CFClient::db_table "facemap"; |
865 | $FACEMAP = CFClient::db_table "facemap"; |
750 | |
866 | |
751 | CFClient::read_cfg "$Crossfire::VARDIR/pclientrc"; |
867 | CFClient::read_cfg "$Crossfire::VARDIR/pclientrc"; |
… | |
… | |
757 | fullscreen => 0, |
873 | fullscreen => 0, |
758 | fast => 0, |
874 | fast => 0, |
759 | fow_enable => 1, |
875 | fow_enable => 1, |
760 | fow_intensity => 0.45, |
876 | fow_intensity => 0.45, |
761 | fow_smooth => 0, |
877 | fow_smooth => 0, |
|
|
878 | gui_fontsize => 1, |
762 | log_fontsize => 14, |
879 | log_fontsize => 14, |
763 | mapsize => 100, |
880 | mapsize => 100, |
764 | host => "crossfire.schmorp.de", |
881 | host => "crossfire.schmorp.de", |
765 | say_command => 'say', |
882 | say_command => 'say', |
|
|
883 | audio_enable => 1, |
|
|
884 | bgm_enable => 1, |
|
|
885 | bgm_volume => 64, |
766 | ); |
886 | ); |
767 | |
887 | |
768 | while (my ($k, $v) = each %DEF_CFG) { |
888 | while (my ($k, $v) = each %DEF_CFG) { |
769 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
889 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
770 | } |
890 | } |
771 | |
891 | |
772 | sdl_init; |
892 | sdl_init; |
773 | |
893 | |
774 | @SDL_MODES = reverse |
894 | @SDL_MODES = reverse |
775 | grep $_->[0] >= 640 && $_->[1] >= 480, |
895 | grep $_->[0] >= 640 && $_->[1] >= 480, |
776 | map [SDL::RectW ($_), SDL::RectH ($_)], |
896 | CFClient::SDL_ListModes; |
777 | @{ SDL::ListModes 0, SDL_FULLSCREEN | SDL_HWSURFACE | SDL_OPENGL }; |
|
|
778 | |
897 | |
779 | @SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; |
898 | @SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; |
780 | |
899 | |
781 | $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES; |
900 | $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES; |
782 | |
|
|
783 | init_screen; |
|
|
784 | |
901 | |
785 | { |
902 | { |
786 | my @fonts = map CFClient::find_rcfile $_, qw(uifont.ttf uifontb.ttf uifonti.ttf uifontbi.ttf); |
903 | my @fonts = map CFClient::find_rcfile $_, qw(uifont.ttf uifontb.ttf uifonti.ttf uifontbi.ttf); |
787 | |
904 | |
788 | CFClient::add_font $_ for @fonts; |
905 | CFClient::add_font $_ for @fonts; |
789 | CFClient::set_font $fonts[0]; |
906 | CFClient::set_font $fonts[0]; |
790 | } |
907 | } |
791 | |
908 | |
|
|
909 | video_init; |
|
|
910 | audio_init; |
|
|
911 | |
792 | Event::loop; |
912 | Event::loop; |
793 | |
913 | |
|
|
914 | END { CFClient::SDL_Quit } |
794 | |
915 | |
|
|
916 | |