… | |
… | |
8 | |
8 | |
9 | use SDL; |
9 | use SDL; |
10 | use SDL::App; |
10 | use SDL::App; |
11 | use SDL::Event; |
11 | use SDL::Event; |
12 | use SDL::Surface; |
12 | use SDL::Surface; |
|
|
13 | |
|
|
14 | use SDL::Mixer; |
|
|
15 | use SDL::Sound; |
|
|
16 | use SDL::Music; |
|
|
17 | |
13 | use SDL::OpenGL; |
18 | use SDL::OpenGL; |
14 | |
19 | |
15 | use Crossfire; |
20 | use Crossfire; |
16 | use Crossfire::Protocol; |
21 | use Crossfire::Protocol; |
17 | |
22 | |
|
|
23 | use Compress::LZF; |
|
|
24 | |
18 | use CFClient; |
25 | use CFClient; |
19 | use CFClient::UI; |
26 | use CFClient::UI; |
20 | |
27 | |
21 | our $VERSION = '0.1'; |
28 | our $VERSION = '0.1'; |
22 | |
29 | |
23 | my $MAX_FPS = 60; |
30 | my $MAX_FPS = 60; |
24 | my $MIN_FPS = 5; # unused as of yet |
31 | my $MIN_FPS = 5; # unused as of yet |
25 | |
32 | |
|
|
33 | our $META_SERVER = "crossfire.real-time.com:13326"; |
|
|
34 | |
|
|
35 | our $FACEMAP; |
|
|
36 | our $TILECACHE; |
26 | our $FACECACHE; |
37 | our $MAPCACHE; |
27 | |
38 | |
28 | our $LAST_REFRESH; |
39 | our $LAST_REFRESH; |
29 | our $NOW; |
40 | our $NOW; |
30 | |
41 | |
31 | our $CFG; |
42 | our $CFG; |
… | |
… | |
38 | our $FULLSCREEN; |
49 | our $FULLSCREEN; |
39 | our $FONTSIZE; |
50 | our $FONTSIZE; |
40 | |
51 | |
41 | our $MAP; |
52 | our $MAP; |
42 | our $MAPWIDGET; |
53 | our $MAPWIDGET; |
|
|
54 | our $BUTTONBAR; |
|
|
55 | our $LOGVIEW; |
|
|
56 | our $CONSOLE; |
|
|
57 | our $METASERVER; |
|
|
58 | |
|
|
59 | our $GAUGES; |
43 | |
60 | |
44 | our $SDL_ACTIVE; |
61 | our $SDL_ACTIVE; |
45 | our $SDL_EV; |
62 | our $SDL_EV; |
46 | our %SDL_CB; |
63 | our %SDL_CB; |
47 | |
64 | |
|
|
65 | our $SDL_MIXER; |
|
|
66 | our @SOUNDS; # event => file mapping |
|
|
67 | our %AUDIO_CHUNKS; # audio files |
|
|
68 | |
48 | our $ALT_ENTER_MESSAGE; |
69 | our $ALT_ENTER_MESSAGE; |
49 | our $STATUS_LINE; |
70 | our $STATUS_LINE; |
50 | our $DEBUG_STATUS; |
71 | our $DEBUG_STATUS; |
51 | our $BUTTONBAR; |
|
|
52 | our $LOGVIEW; |
|
|
53 | |
72 | |
54 | sub status { |
73 | sub status { |
55 | $STATUS_LINE->set_text ($_[0]); |
74 | $STATUS_LINE->set_text ($_[0]); |
56 | my ($w, $h) = $STATUS_LINE->size_request; |
|
|
57 | $STATUS_LINE->size_allocate (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $h, $w, $h); |
75 | $STATUS_LINE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $STATUS_LINE->{h}); |
58 | } |
76 | } |
59 | |
77 | |
60 | sub debug { |
78 | sub debug { |
61 | $DEBUG_STATUS->set_text ($_[0]); |
79 | $DEBUG_STATUS->set_text ($_[0]); |
62 | my ($w, $h) = $DEBUG_STATUS->size_request; |
80 | $DEBUG_STATUS->move ($WIDTH - $DEBUG_STATUS->{w}, 0, $DEBUG_STATUS->{w}, $DEBUG_STATUS->{h}); |
63 | $DEBUG_STATUS->size_allocate ($WIDTH - $w, 0, $w, $h); |
|
|
64 | } |
81 | } |
65 | |
82 | |
66 | sub start_game { |
83 | sub start_game { |
67 | status "logging in..."; |
84 | status "logging in..."; |
68 | |
85 | |
69 | my $mapsize = List::Util::min 64, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; |
86 | my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; |
|
|
87 | |
|
|
88 | $MAPCACHE = CFClient::db_table "mapcache_$CFG->{host}"; |
70 | |
89 | |
71 | $MAP = new CFClient::Map $mapsize, $mapsize; |
90 | $MAP = new CFClient::Map $mapsize, $mapsize; |
|
|
91 | |
|
|
92 | my ($host, $port) = split /:/, $CFG->{host}; |
72 | |
93 | |
73 | $CONN = new conn |
94 | $CONN = new conn |
74 | host => $CFG->{host}, |
95 | host => $host, |
75 | port => $CFG->{port}, |
96 | port => $port || 13327, |
76 | user => $CFG->{user}, |
97 | user => $CFG->{user}, |
77 | pass => $CFG->{password}, |
98 | pass => $CFG->{password}, |
78 | mapw => $mapsize, |
99 | mapw => $mapsize, |
79 | maph => $mapsize, |
100 | maph => $mapsize, |
80 | ; |
101 | ; |
… | |
… | |
86 | |
107 | |
87 | sub stop_game { |
108 | sub stop_game { |
88 | undef $CONN; |
109 | undef $CONN; |
89 | } |
110 | } |
90 | |
111 | |
91 | sub config_dialog { |
112 | sub client_setup { |
92 | my $dialog = new CFClient::UI::FancyFrame |
113 | my $dialog = new CFClient::UI::FancyFrame |
93 | child => (my $vbox = new CFClient::UI::VBox); |
114 | child => (my $vbox = new CFClient::UI::VBox); |
94 | $vbox->add (new CFClient::UI::Label align => 0, text => "Client Setup"); |
115 | $vbox->add (new CFClient::UI::Label align => 0, text => "Client Setup"); |
95 | $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); |
116 | $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); |
96 | |
117 | |
… | |
… | |
134 | |
155 | |
135 | $table->add (0, 5, new CFClient::UI::Label align => 1, text => "FoW Smooth"); |
156 | $table->add (0, 5, new CFClient::UI::Label align => 1, text => "FoW Smooth"); |
136 | $table->add (1, 5, new CFClient::UI::CheckBox state => $CFG->{fow_smooth}, connect_changed => sub { |
157 | $table->add (1, 5, new CFClient::UI::CheckBox state => $CFG->{fow_smooth}, connect_changed => sub { |
137 | my ($self, $value) = @_; |
158 | my ($self, $value) = @_; |
138 | $CFG->{fow_smooth} = $value; |
159 | $CFG->{fow_smooth} = $value; |
|
|
160 | status "Fog of War smoothing requires OpenGL 1.2 or higher" if $CFClient::GL_VERSION < 1.2; |
139 | }); |
161 | }); |
140 | |
162 | |
|
|
163 | $table->add (0, 6, new CFClient::UI::Label align => 1, text => "Log Fontsize"); |
|
|
164 | $table->add (1, 6, new CFClient::UI::Slider range => [$CFG->{log_fontsize}, 8, 30, 1], connect_changed => sub { |
|
|
165 | my ($self, $value) = @_; |
|
|
166 | $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = int $value); |
|
|
167 | }); |
|
|
168 | |
141 | $table->add (1, 6, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { |
169 | $table->add (1, 7, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { |
142 | destroy_screen (); |
170 | video_shutdown (); |
143 | init_screen (); |
171 | video_init (); |
144 | }); |
172 | }); |
|
|
173 | |
|
|
174 | $table->add (0, 8, new CFClient::UI::Label align => 1, text => "Sound"); |
|
|
175 | $table->add (1, 8, new CFClient::UI::CheckBox state => $CFG->{sound}, connect_changed => sub { |
|
|
176 | my ($self, $value) = @_; |
|
|
177 | $CFG->{sound} = $value; |
|
|
178 | }); |
|
|
179 | $table->add (0, 9, new CFClient::UI::Label align => 1, text => "Bg. Music"); |
|
|
180 | $table->add (1, 9, new CFClient::UI::CheckBox state => $CFG->{bg_music_enable}, connect_changed => sub { |
|
|
181 | my ($self, $value) = @_; |
|
|
182 | $CFG->{bg_music_enable} = $value; |
|
|
183 | }); |
|
|
184 | $table->add (1, 10, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { |
|
|
185 | audio_shutdown (); |
|
|
186 | audio_init (); |
|
|
187 | }); |
|
|
188 | |
|
|
189 | $dialog |
|
|
190 | } |
|
|
191 | |
|
|
192 | sub metaserver_dialog { |
|
|
193 | my $dialog = new CFClient::UI::FancyFrame |
|
|
194 | child => (my $vbox = new CFClient::UI::VBox); |
|
|
195 | |
|
|
196 | $vbox->add ($dialog->{table} = new CFClient::UI::Table); |
|
|
197 | |
|
|
198 | $dialog |
|
|
199 | } |
|
|
200 | |
|
|
201 | sub update_metaserver { |
|
|
202 | my ($HOST) = @_; |
|
|
203 | |
|
|
204 | status "fetching metaserver list..."; |
|
|
205 | |
|
|
206 | my $buf; |
|
|
207 | |
|
|
208 | my $fh = new IO::Socket::INET PeerHost => $META_SERVER, Blocking => 0; |
|
|
209 | |
|
|
210 | Event->io (fd => $fh, poll => 'r', cb => sub { |
|
|
211 | my $res = sysread $fh, $buf, 8192, length $buf; |
|
|
212 | |
|
|
213 | if (!defined $res) { |
|
|
214 | $_[0]->w->cancel; |
|
|
215 | status "metaserver: $!"; |
|
|
216 | } elsif ($res == 0) { |
|
|
217 | $_[0]->w->cancel; |
|
|
218 | status "server list retrieved"; |
|
|
219 | |
|
|
220 | my $table = $METASERVER->{table}; |
|
|
221 | |
|
|
222 | $table->clear; |
|
|
223 | |
|
|
224 | my @col = qw(Use #Users Host Uptime Version Description); |
|
|
225 | $table->add ($_, 0, new CFClient::UI::Label align => 0, fg => [1, 1, 0], text => $col[$_]) |
|
|
226 | for 0 .. $#col; |
|
|
227 | |
|
|
228 | my @align = qw(1 0 1 1 -1); |
|
|
229 | |
|
|
230 | my $y = 0; |
|
|
231 | for my $m (sort { $b->[3] <=> $a->[3] } map [split /\|/], split /\015?\012/, $buf) { |
|
|
232 | my ($ip, $last, $host, $users, $version, $desc, $ibytes, $obytes, $uptime) = @$m; |
|
|
233 | |
|
|
234 | for ($desc) { |
|
|
235 | s/<br>/\n/gi; |
|
|
236 | s/<li>/\n· /gi; |
|
|
237 | s/<.*?>//sgi; |
|
|
238 | s/&/&/g; |
|
|
239 | s/</</g; |
|
|
240 | s/>/>/g; |
|
|
241 | } |
|
|
242 | |
|
|
243 | $uptime = sprintf "%dd %02d:%02d:%02d", |
|
|
244 | (int $m->[8] / 86400), |
|
|
245 | (int $m->[8] / 3600) % 24, |
|
|
246 | (int $m->[8] / 60) % 60, |
|
|
247 | $m->[8] % 60; |
|
|
248 | |
|
|
249 | $m = [$users, $host, $uptime, $version, $desc]; |
|
|
250 | |
|
|
251 | $y++; |
|
|
252 | |
|
|
253 | $table->add (0, $y, new CFClient::UI::VBox children => [ |
|
|
254 | (new CFClient::UI::Button text => " ", connect_activate => sub { |
|
|
255 | $HOST->set_text ($CFG->{host} = $host); |
|
|
256 | }), |
|
|
257 | (new CFClient::UI::Empty expand => 1), |
|
|
258 | ]); |
|
|
259 | |
|
|
260 | $table->add ($_ + 1, $y, new CFClient::UI::Label align => $align[$_], text => $m->[$_], fontsize => $FONTSIZE * 0.8) |
|
|
261 | for 0 .. $#$m; |
|
|
262 | } |
|
|
263 | } |
|
|
264 | }); |
|
|
265 | } |
|
|
266 | |
|
|
267 | sub server_setup { |
|
|
268 | my $dialog = new CFClient::UI::FancyFrame |
|
|
269 | child => (my $vbox = new CFClient::UI::VBox); |
145 | |
270 | |
146 | $vbox->add (new CFClient::UI::Label align => 0, text => "Server Setup"); |
271 | $vbox->add (new CFClient::UI::Label align => 0, text => "Server Setup"); |
147 | $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); |
272 | $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); |
148 | $table->add (0, 2, new CFClient::UI::Label align => 1, text => "Host"); |
273 | $table->add (0, 2, new CFClient::UI::Label align => 1, text => "Host:Port"); |
149 | $table->add (1, 2, my $host = new CFClient::UI::Entry text => $CFG->{host}); |
274 | |
150 | |
275 | { |
151 | $table->add (0, 3, new CFClient::UI::Label align => 1, text => "Port"); |
276 | $table->add (1, 2, my $vbox = new CFClient::UI::VBox); |
152 | $table->add (1, 3, my $port = new CFClient::UI::Entry text => $CFG->{port}); |
277 | |
|
|
278 | $vbox->add (my $HOST = new CFClient::UI::Entry text => $CFG->{host}, connect_changed => sub { |
|
|
279 | my ($self, $value) = @_; |
|
|
280 | $CFG->{host} = $value; |
|
|
281 | }); |
|
|
282 | |
|
|
283 | $METASERVER = metaserver_dialog; |
|
|
284 | |
|
|
285 | $vbox->add (new CFClient::UI::Flopper text => "Metaserver", other => $METASERVER, connect_open => sub { |
|
|
286 | update_metaserver $HOST; |
|
|
287 | }); |
|
|
288 | } |
153 | |
289 | |
154 | $table->add (0, 4, new CFClient::UI::Label align => 1, text => "Username"); |
290 | $table->add (0, 4, new CFClient::UI::Label align => 1, text => "Username"); |
155 | $table->add (1, 4, my $user = new CFClient::UI::Entry text => $CFG->{user}); |
291 | $table->add (1, 4, new CFClient::UI::Entry text => $CFG->{user}, connect_changed => sub { |
|
|
292 | my ($self, $value) = @_; |
|
|
293 | $CFG->{user} = $value; |
|
|
294 | }); |
156 | |
295 | |
157 | $table->add (0, 5, new CFClient::UI::Label align => 1, text => "Password"); |
296 | $table->add (0, 5, new CFClient::UI::Label align => 1, text => "Password"); |
158 | $table->add (1, 5, my $pass = new CFClient::UI::Entry text => $CFG->{password}, hidden => 1); |
297 | $table->add (1, 5, new CFClient::UI::Entry text => $CFG->{password}, hidden => 1, connect_changed => sub { |
|
|
298 | my ($self, $value) = @_; |
|
|
299 | $CFG->{password} = $value; |
|
|
300 | }); |
159 | |
301 | |
|
|
302 | $table->add (0, 6, new CFClient::UI::Label align => 1, text => "Def. say cmd"); |
|
|
303 | $table->add (1, 6, my $saycmd = new CFClient::UI::Entry text => $CFG->{say_command}, connect_changed => sub { |
|
|
304 | my ($self, $value) = @_; |
|
|
305 | $CFG->{say_command} = $value; |
|
|
306 | }); |
|
|
307 | |
160 | $table->add (0, 6, new CFClient::UI::Label align => 1, text => "Map Size"); |
308 | $table->add (0, 7, new CFClient::UI::Label align => 1, text => "Map Size"); |
161 | $table->add (1, 6, new CFClient::UI::Slider |
309 | $table->add (1, 7, new CFClient::UI::Slider |
162 | req_w => 100, |
310 | req_w => 100, |
163 | range => [$CFG->{mapsize}, 10, 100 + 1, 1], |
311 | range => [$CFG->{mapsize}, 10, 100 + 1, 1], |
164 | connect_changed => sub { |
312 | connect_changed => sub { |
165 | my ($self, $value) = @_; |
313 | my ($self, $value) = @_; |
166 | |
314 | |
167 | $CFG->{mapsize} = $self->{range}[0] = $value = int $value; |
315 | $CFG->{mapsize} = $self->{range}[0] = $value = int $value; |
168 | }, |
316 | }, |
169 | ); |
317 | ); |
170 | |
318 | |
171 | $table->add (1, 7, new CFClient::UI::Button expand => 1, align => 0, text => "Login", connect_activate => sub { |
319 | $table->add (1, 8, new CFClient::UI::Button expand => 1, align => 0, text => "Login", connect_activate => sub { |
172 | start_game; |
320 | start_game; |
173 | }); |
321 | }); |
174 | |
322 | |
175 | $vbox->add (my $hbox = new CFClient::UI::HBox); |
|
|
176 | |
|
|
177 | $hbox->add (new CFClient::UI::Button expand => 1, align => 0, text => "Save", connect_activate => sub { |
|
|
178 | CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; |
|
|
179 | status "Configuration Saved"; |
|
|
180 | }); |
|
|
181 | |
|
|
182 | $dialog |
323 | $dialog |
183 | } |
324 | } |
184 | |
325 | |
185 | sub console_window { |
326 | sub message_window { |
186 | my $window = new CFClient::UI::FancyFrame |
327 | my $window = new CFClient::UI::FancyFrame |
187 | border_bg => [1, 1, 1, 0.5], |
328 | border_bg => [1, 1, 1, 0.5], |
188 | bg => [0.3, 0.3, 0.3, 0.8], |
329 | bg => [0.3, 0.3, 0.3, 0.8], |
|
|
330 | user_w => int $::WIDTH / 3, |
|
|
331 | user_h => int $::HEIGHT / 5, |
189 | child => (my $vbox = new CFClient::UI::VBox); |
332 | child => (my $vbox = new CFClient::UI::VBox); |
190 | |
333 | |
191 | $vbox->add ($LOGVIEW = new CFClient::UI::TextView expand => 1); |
334 | $vbox->add ($LOGVIEW = new CFClient::UI::TextView |
|
|
335 | expand => 1, |
|
|
336 | fontsize => $::CFG->{log_fontsize}, |
|
|
337 | ); |
|
|
338 | |
192 | $vbox->add (my $input = new CFClient::UI::Entry); |
339 | $vbox->add (my $input = new CFClient::UI::Entry |
|
|
340 | connect_focus_in => sub { |
|
|
341 | my ($input, $prev_focus) = @_; |
|
|
342 | |
|
|
343 | delete $input->{refocus_map}; |
|
|
344 | |
|
|
345 | if ($prev_focus == $MAPWIDGET && $input->{auto_activated}) { |
|
|
346 | $input->{refocus_map} = 1; |
|
|
347 | } |
|
|
348 | delete $input->{auto_activated}; |
|
|
349 | }, |
|
|
350 | connect_activate => sub { |
|
|
351 | my ($input, $text) = @_; |
|
|
352 | $input->set_text (''); |
|
|
353 | |
|
|
354 | if ($text =~ /^\/(.*)/) { |
|
|
355 | $::CONN->user_send ($1); |
|
|
356 | } else { |
|
|
357 | my $say_cmd = $::CFG->{say_command} || 'say'; |
|
|
358 | $::CONN->user_send ("$say_cmd $text"); |
|
|
359 | } |
|
|
360 | if ($input->{refocus_map}) { |
|
|
361 | delete $input->{refocus_map}; |
|
|
362 | $MAPWIDGET->focus_in |
|
|
363 | } |
|
|
364 | }, |
|
|
365 | connect_escape => sub { |
|
|
366 | $MAPWIDGET->focus_in |
|
|
367 | }, |
|
|
368 | ); |
|
|
369 | |
|
|
370 | $CONSOLE = { |
|
|
371 | window => $window, |
|
|
372 | input => $input |
|
|
373 | }; |
193 | |
374 | |
194 | $window |
375 | $window |
195 | } |
376 | } |
196 | |
377 | |
197 | sub sdl_init { |
378 | sub sdl_init { |
|
|
379 | #SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE |
198 | SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO |
380 | SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO |
199 | and die "SDL::Init failed!\n"; |
381 | and die "SDL::Init failed!\n"; |
200 | } |
382 | } |
201 | |
383 | |
202 | sub init_screen { |
384 | sub video_init { |
203 | sdl_init; |
385 | sdl_init; |
204 | |
386 | |
205 | ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; |
387 | ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; |
206 | $FULLSCREEN = $CFG->{fullscreen}; |
388 | $FULLSCREEN = $CFG->{fullscreen}; |
207 | $FAST = $CFG->{fast}; |
389 | $FAST = $CFG->{fast}; |
208 | |
390 | |
209 | SDL::GLSetAttribute SDL_GL_RED_SIZE, 5; |
391 | SDL::GLSetAttribute SDL_GL_RED_SIZE, 5; |
210 | SDL::GLSetAttribute SDL_GL_GREEN_SIZE, 5; |
392 | SDL::GLSetAttribute SDL_GL_GREEN_SIZE, 5; |
211 | SDL::GLSetAttribute SDL_GL_BLUE_SIZE, 5; |
393 | SDL::GLSetAttribute SDL_GL_BLUE_SIZE, 5; |
212 | SDL::GLSetAttribute SDL_GL_ALPHA_SIZE, 0; |
394 | SDL::GLSetAttribute SDL_GL_ALPHA_SIZE, 1; |
213 | |
395 | |
214 | SDL::GLSetAttribute SDL_GL_ACCUM_RED_SIZE, 0; |
396 | SDL::GLSetAttribute SDL_GL_ACCUM_RED_SIZE, 0; |
215 | SDL::GLSetAttribute SDL_GL_ACCUM_GREEN_SIZE, 0; |
397 | SDL::GLSetAttribute SDL_GL_ACCUM_GREEN_SIZE, 0; |
216 | SDL::GLSetAttribute SDL_GL_ACCUM_BLUE_SIZE, 0; |
398 | SDL::GLSetAttribute SDL_GL_ACCUM_BLUE_SIZE, 0; |
217 | SDL::GLSetAttribute SDL_GL_ACCUM_ALPHA_SIZE, 0; |
399 | SDL::GLSetAttribute SDL_GL_ACCUM_ALPHA_SIZE, 0; |
… | |
… | |
239 | $FONTSIZE = int $HEIGHT / 40; |
421 | $FONTSIZE = int $HEIGHT / 40; |
240 | |
422 | |
241 | ############################################################################# |
423 | ############################################################################# |
242 | |
424 | |
243 | $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100; |
425 | $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100; |
244 | $CFClient::UI::TOPLEVEL->add ($DEBUG_STATUS); |
426 | $CFClient::UI::ROOT->add ($DEBUG_STATUS); |
245 | |
427 | |
246 | $STATUS_LINE = new CFClient::UI::Label |
428 | $STATUS_LINE = new CFClient::UI::Label |
247 | padding => 0, |
429 | padding => 0, |
248 | y => $HEIGHT * 44 / 45 - $FONTSIZE; |
430 | y => $HEIGHT * 44 / 45 - $FONTSIZE; |
249 | $CFClient::UI::TOPLEVEL->add ($STATUS_LINE); |
431 | $CFClient::UI::ROOT->add ($STATUS_LINE); |
250 | |
432 | |
251 | $ALT_ENTER_MESSAGE = new CFClient::UI::Label |
433 | $ALT_ENTER_MESSAGE = new CFClient::UI::Label |
252 | padding => 0, |
434 | padding => 0, |
253 | y => $HEIGHT * 44 / 45, |
435 | y => $HEIGHT * 44 / 45, |
254 | height => $HEIGHT / 45, |
436 | fontsize => $HEIGHT / 45, |
255 | text => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; |
437 | markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; |
256 | $CFClient::UI::TOPLEVEL->add ($ALT_ENTER_MESSAGE); |
438 | $CFClient::UI::ROOT->add ($ALT_ENTER_MESSAGE); |
257 | |
439 | |
258 | $CFClient::UI::TOPLEVEL->add ($MAPWIDGET = new CFClient::UI::MapWidget); |
440 | $CFClient::UI::ROOT->add ($MAPWIDGET = new CFClient::UI::MapWidget); |
259 | $MAPWIDGET->focus_in; |
441 | $MAPWIDGET->focus_in; |
|
|
442 | $MAPWIDGET->connect (activate_console => sub { |
|
|
443 | my ($mapwidget, $preset) = @_; |
260 | |
444 | |
|
|
445 | if ($CONSOLE) { |
|
|
446 | $CONSOLE->{input}->{auto_activated} = 1; |
|
|
447 | $CONSOLE->{input}->focus_in; |
|
|
448 | |
|
|
449 | if ($preset && $CONSOLE->{input}->get_text eq '') { |
|
|
450 | $CONSOLE->{input}->set_text ($preset); |
|
|
451 | } |
|
|
452 | } |
|
|
453 | }); |
|
|
454 | |
261 | $CFClient::UI::TOPLEVEL->add ($BUTTONBAR = new CFClient::UI::HBox); |
455 | $CFClient::UI::ROOT->add ($BUTTONBAR = new CFClient::UI::HBox); |
262 | |
456 | |
263 | $BUTTONBAR->add (my $setup = new CFClient::UI::Flopper x => 0, y => 0, text => "Setup", other => config_dialog, state => 1); |
457 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Client Setup", other => client_setup); |
264 | $BUTTONBAR->add (my $setup = new CFClient::UI::Flopper x => 0, y => 0, text => "Console", other => console_window); |
458 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Server Setup", other => server_setup); |
265 | } |
459 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => message_window); |
266 | |
460 | |
267 | sub destroy_screen { |
461 | $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub { |
|
|
462 | CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; |
|
|
463 | status "Configuration Saved"; |
|
|
464 | }); |
|
|
465 | |
|
|
466 | $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup |
|
|
467 | |
|
|
468 | my $tgw = new CFClient::UI::FancyFrame (x => $WIDTH - 300, y => 0); |
|
|
469 | $tgw->add (my $hbox = new CFClient::UI::HBox ()); |
|
|
470 | |
|
|
471 | $hbox->add (my $hg = new CFClient::UI::VGauge (gauge => 'hp')); |
|
|
472 | $hbox->add (my $mg = new CFClient::UI::VGauge (gauge => 'mana')); |
|
|
473 | $hbox->add (my $gg = new CFClient::UI::VGauge (gauge => 'grace')); |
|
|
474 | $hbox->add (my $fg = new CFClient::UI::VGauge (gauge => 'food')); |
|
|
475 | |
|
|
476 | $GAUGES = { food => $fg, mana => $mg, hp => $hg, grace => $gg }; |
|
|
477 | $CFClient::UI::ROOT->add ($tgw); |
|
|
478 | } |
|
|
479 | |
|
|
480 | sub video_shutdown { |
268 | $CFClient::UI::TOPLEVEL->{children} = []; |
481 | $CFClient::UI::ROOT->{children} = []; |
269 | undef $SDL_ACTIVE; |
482 | undef $SDL_ACTIVE; |
270 | undef $SDL_EV; |
483 | undef $SDL_EV; |
271 | SDL::Quit; |
484 | } |
|
|
485 | |
|
|
486 | my $bgmusic;#TODO#hack#d# |
|
|
487 | |
|
|
488 | sub audio_init { |
|
|
489 | if ($CFG->{sound} || 1) { |
|
|
490 | if (open my $fh, "<:utf8", CFClient::find_rcfile "sounds/config") { |
|
|
491 | $SDL_MIXER = new SDL::Mixer; |
|
|
492 | $SDL_MIXER->allocate_channels (8); |
|
|
493 | |
|
|
494 | if ($CFG->{bg_music_enable}) { |
|
|
495 | $bgmusic = new SDL::Music CFClient::find_rcfile "music/game3.ogg"; |
|
|
496 | $SDL_MIXER->play_music ($bgmusic, -1); |
|
|
497 | } |
|
|
498 | |
|
|
499 | while (<$fh>) { |
|
|
500 | next if /^\s*#/; |
|
|
501 | next if /^\s*$/; |
|
|
502 | |
|
|
503 | my ($file, $volume, $event) = split /\s+/, $_, 3; |
|
|
504 | |
|
|
505 | push @SOUNDS, "$volume,$file"; |
|
|
506 | |
|
|
507 | $AUDIO_CHUNKS{"$volume,$file"} ||= do { |
|
|
508 | my $chunk = new SDL::Sound CFClient::find_rcfile "sounds/$file"; |
|
|
509 | $chunk->volume ($volume * 128 / 100); |
|
|
510 | $chunk |
|
|
511 | }; |
|
|
512 | } |
|
|
513 | } else { |
|
|
514 | status "unable to open sound config: $!"; |
|
|
515 | } |
|
|
516 | } |
|
|
517 | } |
|
|
518 | |
|
|
519 | sub audio_shutdown { |
|
|
520 | undef $SDL_MIXER; |
|
|
521 | @SOUNDS = (); |
|
|
522 | %AUDIO_CHUNKS = (); |
272 | } |
523 | } |
273 | |
524 | |
274 | my %animate_object; |
525 | my %animate_object; |
275 | my $animate_timer; |
526 | my $animate_timer; |
276 | |
527 | |
… | |
… | |
284 | debug sprintf "%3.2f", $fps; |
535 | debug sprintf "%3.2f", $fps; |
285 | |
536 | |
286 | $want_refresh = 0; |
537 | $want_refresh = 0; |
287 | $can_refresh = 0; |
538 | $can_refresh = 0; |
288 | |
539 | |
289 | glViewport 0, 0, $WIDTH, $HEIGHT; |
|
|
290 | |
|
|
291 | glMatrixMode GL_PROJECTION; |
|
|
292 | glLoadIdentity; |
|
|
293 | glOrtho 0, $WIDTH, $HEIGHT, 0, -10000 , 10000; |
|
|
294 | glMatrixMode GL_MODELVIEW; |
|
|
295 | glLoadIdentity; |
|
|
296 | |
|
|
297 | glClearColor +($CFG->{fow_intensity}) x 3, 1; |
|
|
298 | glClear GL_COLOR_BUFFER_BIT; |
|
|
299 | |
|
|
300 | $CFClient::UI::TOPLEVEL->draw; |
540 | $CFClient::UI::ROOT->draw; |
301 | |
541 | |
302 | SDL::GLSwapBuffers; |
542 | SDL::GLSwapBuffers; |
303 | |
543 | |
304 | $LAST_REFRESH = $NOW; |
544 | $LAST_REFRESH = $NOW; |
305 | } |
545 | } |
… | |
… | |
336 | delete $animate_object{$widget}; |
576 | delete $animate_object{$widget}; |
337 | } |
577 | } |
338 | |
578 | |
339 | @conn::ISA = Crossfire::Protocol::; |
579 | @conn::ISA = Crossfire::Protocol::; |
340 | |
580 | |
|
|
581 | sub conn::stats_update { |
|
|
582 | my ($self, $stats) = @_; |
|
|
583 | |
|
|
584 | # i love text protocols!!! |
|
|
585 | # FIXME: the stats are somehow weird |
|
|
586 | my $hp = $stats->{1}; |
|
|
587 | my $hp_m = $stats->{2}; |
|
|
588 | my $sp = $stats->{3}; |
|
|
589 | my $sp_m = $stats->{4}; |
|
|
590 | my $fo = $stats->{18}; |
|
|
591 | my $fo_m = 1000; |
|
|
592 | my $gr = $stats->{23}; |
|
|
593 | my $gr_m = $stats->{24}; |
|
|
594 | |
|
|
595 | #d# warn "DATA $hp $hp_m $sp $sp_m $fo $fo_m $gr $gr_m\n"; |
|
|
596 | $GAUGES->{hp}->set_value ($hp, $hp_m); |
|
|
597 | $GAUGES->{mana}->set_value ($sp, $sp_m); |
|
|
598 | $GAUGES->{food}->set_value ($fo, $fo_m); |
|
|
599 | $GAUGES->{grace}->set_value ($gr, $gr_m); |
|
|
600 | } |
|
|
601 | |
341 | sub conn::user_send { |
602 | sub conn::user_send { |
342 | my ($self, $command) = @_; |
603 | my ($self, $command) = @_; |
343 | |
604 | |
344 | $self->send ($command); |
605 | $self->send_command ($command); |
345 | status $command; |
606 | status $command; |
|
|
607 | } |
|
|
608 | |
|
|
609 | sub conn::map_scroll { |
|
|
610 | my ($self, $dx, $dy) = @_; |
|
|
611 | |
|
|
612 | $MAP->scroll ($dx, $dy); |
346 | } |
613 | } |
347 | |
614 | |
348 | sub conn::feed_map1a { |
615 | sub conn::feed_map1a { |
349 | my ($self, $data) = @_; |
616 | my ($self, $data) = @_; |
350 | |
617 | |
351 | # $self->Crossfire::Protocol::feed_map1a ($data); |
618 | # $self->Crossfire::Protocol::feed_map1a ($data); |
352 | |
619 | |
353 | $MAP->scroll (delete $self->{delayed_scroll_x}, delete $self->{delayed_scroll_y}); |
|
|
354 | $MAP->map1a_update ($data); |
620 | $MAP->map1a_update ($data); |
355 | $MAPWIDGET->update; |
621 | $MAPWIDGET->update; |
356 | } |
622 | } |
357 | |
623 | |
358 | #sub conn::map_update { |
624 | sub conn::flush_map { |
359 | # my ($self, $dirty) = @_; |
625 | my ($self) = @_; |
360 | # |
626 | |
361 | # $MAPWIDGET->update; |
627 | my $map_info = delete $self->{map_info} |
362 | #} |
628 | or return; |
|
|
629 | |
|
|
630 | my ($hash, $x, $y, $w, $h) = @$map_info; |
|
|
631 | |
|
|
632 | my $data = $MAP->get_rect ($x, $y, $w, $h); |
|
|
633 | $MAPCACHE->put ($hash => Compress::LZF::compress $data); |
|
|
634 | |
|
|
635 | warn sprintf "SAVEmap[%s] length %d\n", $hash, length $data;#d# |
|
|
636 | |
|
|
637 | } |
363 | |
638 | |
364 | sub conn::map_clear { |
639 | sub conn::map_clear { |
365 | my ($self) = @_; |
640 | my ($self) = @_; |
366 | |
641 | |
|
|
642 | $self->flush_map; |
|
|
643 | delete $self->{neigh}; |
|
|
644 | |
367 | $MAP->clear; |
645 | $MAP->clear; |
|
|
646 | } |
368 | |
647 | |
369 | # refresh; |
648 | |
|
|
649 | sub conn::load_map($$$) { |
|
|
650 | my ($self, $hash, $x, $y) = @_; |
|
|
651 | |
|
|
652 | if (defined (my $data = $MAPCACHE->get ($hash))) { |
|
|
653 | $data = Compress::LZF::decompress $data; |
|
|
654 | warn sprintf "LOADmap[%s,%d,%d] length %d\n", $hash, $x, $y, length $data;#d# |
|
|
655 | for my $id ($MAP->set_rect ($x, $y, $data)) { |
|
|
656 | my $data = $TILECACHE->get ($id) |
|
|
657 | or next; |
|
|
658 | |
|
|
659 | $self->set_texture ($id => $data); |
|
|
660 | } |
|
|
661 | } |
|
|
662 | } |
|
|
663 | |
|
|
664 | sub conn::flood_fill { |
|
|
665 | my ($self, $path, $hash, $flags, $x0, $y0, $x1, $y1) = @_; |
|
|
666 | |
|
|
667 | # the server does not allow map paths > 6 |
|
|
668 | return if 6 <= length $path; |
|
|
669 | |
|
|
670 | for my $tile (1..4) { |
|
|
671 | next if $self->{neigh}{$hash}[$tile]; |
|
|
672 | next unless $flags & (1 << ($tile - 1)); |
|
|
673 | |
|
|
674 | my $neigh = $self->{neigh}{$hash} ||= []; |
|
|
675 | |
|
|
676 | $self->send_mapinfo ("spatial $path$tile", sub { |
|
|
677 | my ($mode, $flags, $x, $y, $w, $h, $hash) = @_; |
|
|
678 | |
|
|
679 | #warn "map<$path>_$tile=<$mode,$x,$y,$w,$h,$hash>\n";#d# |
|
|
680 | return if $mode ne "spatial"; |
|
|
681 | |
|
|
682 | $x += $MAP->ox; |
|
|
683 | $y += $MAP->oy; |
|
|
684 | |
|
|
685 | $self->load_map ($hash, $x, $y) |
|
|
686 | unless $self->{neigh}{$hash}[5]++;#d# |
|
|
687 | |
|
|
688 | $neigh->[$tile] = [$x, $y, $w, $h]; |
|
|
689 | |
|
|
690 | $self->flood_fill ("$path$tile", $hash, $flags, $x0, $y0, $x1, $y1) |
|
|
691 | if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1; |
|
|
692 | }); |
|
|
693 | } |
|
|
694 | } |
|
|
695 | |
|
|
696 | sub conn::map_change { |
|
|
697 | my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_; |
|
|
698 | |
|
|
699 | $self->flush_map; |
|
|
700 | |
|
|
701 | my ($ox, $oy) = ($::MAP->ox, $::MAP->oy); |
|
|
702 | |
|
|
703 | my $mapmapw = 250; |
|
|
704 | my $mapmaph = 250; |
|
|
705 | |
|
|
706 | $self->flood_fill ("", $hash, $flags, |
|
|
707 | $ox - $mapmapw * 0.5, $oy - $mapmapw * 0.5, |
|
|
708 | $ox + $mapmapw * 0.5, $oy + $mapmapw * 0.5); |
|
|
709 | |
|
|
710 | $x += $ox; |
|
|
711 | $y += $oy; |
|
|
712 | |
|
|
713 | $self->{map_info} = [$hash, $x, $y, $w, $h]; |
|
|
714 | |
|
|
715 | $self->load_map ($hash, $x, $y); |
370 | } |
716 | } |
371 | |
717 | |
372 | sub conn::face_find { |
718 | sub conn::face_find { |
373 | my ($self, $face) = @_; |
719 | my ($self, $facenum, $face) = @_; |
374 | |
720 | |
375 | $FACECACHE->{"$face->{chksum},$face->{name}"} |
721 | my $hash = "$face->{chksum},$face->{name}"; |
|
|
722 | |
|
|
723 | my $id = $FACEMAP->get ($hash); |
|
|
724 | |
|
|
725 | unless ($id) { |
|
|
726 | # create new id for face |
|
|
727 | # i love transactions |
|
|
728 | for (1..100) { |
|
|
729 | my $txn = $CFClient::DB_ENV->txn_begin; |
|
|
730 | my $status = $FACEMAP->db_get (id => $id, BerkeleyDB::DB_RMW); |
|
|
731 | if ($status == 0 || $status == BerkeleyDB::DB_NOTFOUND) { |
|
|
732 | $id++; |
|
|
733 | if ($FACEMAP->put (id => $id) == 0 |
|
|
734 | && $FACEMAP->put ($hash => $id) == 0) { |
|
|
735 | $txn->txn_commit; |
|
|
736 | |
|
|
737 | goto gotid; |
|
|
738 | } |
|
|
739 | } |
|
|
740 | $txn->abort; |
|
|
741 | } |
|
|
742 | |
|
|
743 | CFClient::fatal "maximum number of transaction retries reached - database problems?"; |
|
|
744 | } |
|
|
745 | |
|
|
746 | gotid: |
|
|
747 | $face->{id} = $id; |
|
|
748 | $MAP->set_face ($facenum => $id); |
|
|
749 | $TILECACHE->get ($id) |
376 | } |
750 | } |
377 | |
751 | |
378 | sub conn::face_update { |
752 | sub conn::face_update { |
379 | my ($self, $facenum, $face) = @_; |
753 | my ($self, $facenum, $face) = @_; |
380 | |
754 | |
381 | $FACECACHE->{"$face->{chksum},$face->{name}"} = $face->{image}; |
755 | $TILECACHE->put ($face->{id} => $face->{image}); #TODO: try to avoid duplicate writes |
382 | |
756 | |
383 | my $tex = $face->{texture} = new_from_image CFClient::Texture delete $face->{image}; |
757 | $self->set_texture ($face->{id} => delete $face->{image}); |
|
|
758 | } |
384 | |
759 | |
|
|
760 | sub conn::set_texture { |
|
|
761 | my ($self, $id, $data) = @_; |
|
|
762 | |
|
|
763 | $self->{texture}[$id] ||= do { |
|
|
764 | my $tex = |
|
|
765 | new_from_image CFClient::Texture |
|
|
766 | $data, minify => 1; |
|
|
767 | |
385 | $MAP->set_texture ($facenum, @$tex{qw(name w h s t)}); |
768 | $MAP->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}}); |
386 | $MAPWIDGET->update; |
769 | $MAPWIDGET->update; |
|
|
770 | |
|
|
771 | $tex |
|
|
772 | }; |
|
|
773 | } |
|
|
774 | |
|
|
775 | sub conn::sound_play { |
|
|
776 | my ($self, $x, $y, $soundnum, $type) = @_; |
|
|
777 | |
|
|
778 | my $chunk = $AUDIO_CHUNKS{$SOUNDS[$soundnum]} |
|
|
779 | or return; |
|
|
780 | |
|
|
781 | $SDL_MIXER->play_channel (-1, $chunk); |
|
|
782 | warn "sound $x,$y,$soundnum,$type\n";#d# |
387 | } |
783 | } |
388 | |
784 | |
389 | sub conn::query { |
785 | sub conn::query { |
390 | my ($self, $flags, $prompt) = @_; |
786 | my ($self, $flags, $prompt) = @_; |
391 | |
787 | |
… | |
… | |
397 | my ($self, $color, $text) = @_; |
793 | my ($self, $color, $text) = @_; |
398 | |
794 | |
399 | my @color = ( |
795 | my @color = ( |
400 | [1.00, 1.00, 1.00], #[0.00, 0.00, 0.00], |
796 | [1.00, 1.00, 1.00], #[0.00, 0.00, 0.00], |
401 | [1.00, 1.00, 1.00], |
797 | [1.00, 1.00, 1.00], |
402 | [0.00, 0.00, 0.55], |
798 | [0.50, 0.50, 1.00], #[0.00, 0.00, 0.55] |
403 | [1.00, 0.00, 0.00], |
799 | [1.00, 0.00, 0.00], |
404 | [1.00, 0.54, 0.00], |
800 | [1.00, 0.54, 0.00], |
405 | [0.11, 0.56, 1.00], |
801 | [0.11, 0.56, 1.00], |
406 | [0.93, 0.46, 0.00], |
802 | [0.93, 0.46, 0.00], |
407 | [0.18, 0.54, 0.34], |
803 | [0.18, 0.54, 0.34], |
… | |
… | |
425 | refresh; |
821 | refresh; |
426 | }, |
822 | }, |
427 | SDL_KEYDOWN() => sub { |
823 | SDL_KEYDOWN() => sub { |
428 | if ($SDL_EV->key_mod & KMOD_ALT && $SDL_EV->key_sym == SDLK_RETURN) { |
824 | if ($SDL_EV->key_mod & KMOD_ALT && $SDL_EV->key_sym == SDLK_RETURN) { |
429 | # alt-enter |
825 | # alt-enter |
430 | destroy_screen; |
826 | video_shutdown; |
431 | $CFG->{fullscreen} = !$CFG->{fullscreen}; |
827 | $CFG->{fullscreen} = !$CFG->{fullscreen}; |
432 | init_screen; |
828 | video_init; |
433 | } else { |
829 | } else { |
434 | CFClient::UI::feed_sdl_key_down_event ($SDL_EV); |
830 | CFClient::UI::feed_sdl_key_down_event ($SDL_EV); |
435 | } |
831 | } |
436 | }, |
832 | }, |
437 | SDL_KEYUP() => sub { |
833 | SDL_KEYUP() => sub { |
… | |
… | |
451 | }, |
847 | }, |
452 | ); |
848 | ); |
453 | |
849 | |
454 | ############################################################################# |
850 | ############################################################################# |
455 | |
851 | |
|
|
852 | $SIG{INT} = $SIG{TERM} = sub { exit }; |
|
|
853 | |
|
|
854 | $TILECACHE = CFClient::db_table "tilecache"; |
|
|
855 | $FACEMAP = CFClient::db_table "facemap"; |
|
|
856 | |
456 | CFClient::read_cfg "$Crossfire::VARDIR/pclientrc"; |
857 | CFClient::read_cfg "$Crossfire::VARDIR/pclientrc"; |
457 | |
858 | |
458 | my %DEF_CFG = ( |
859 | my %DEF_CFG = ( |
|
|
860 | sdl_mode => 0, |
459 | width => 640, |
861 | width => 640, |
460 | height => 480, |
862 | height => 480, |
|
|
863 | fullscreen => 0, |
461 | fast => 0, |
864 | fast => 0, |
462 | fow_enable => 1, |
865 | fow_enable => 1, |
463 | fow_intensity => 0.45, |
866 | fow_intensity => 0.45, |
464 | fow_smooth => 0, |
867 | fow_smooth => 0, |
465 | fullscreen => 0, |
868 | log_fontsize => 14, |
466 | sdl_mode => 0, |
|
|
467 | mapsize => 100, |
869 | mapsize => 100, |
468 | host => "crossfire.schmorp.de", |
870 | host => "crossfire.schmorp.de", |
|
|
871 | say_command => 'say', |
469 | port => 13327, |
872 | sound => 1, |
|
|
873 | bg_music_enable => 1, |
470 | ); |
874 | ); |
471 | |
875 | |
472 | while (my ($k, $v) = each %DEF_CFG) { |
876 | while (my ($k, $v) = each %DEF_CFG) { |
473 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
877 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
474 | } |
878 | } |
… | |
… | |
482 | |
886 | |
483 | @SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; |
887 | @SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; |
484 | |
888 | |
485 | $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES; |
889 | $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES; |
486 | |
890 | |
487 | init_screen; |
|
|
488 | |
|
|
489 | { |
891 | { |
490 | my @fonts = map CFClient::find_rcfile $_, qw(uifont.ttf uifontb.ttf uifonti.ttf uifontbi.ttf); |
892 | my @fonts = map CFClient::find_rcfile $_, qw(uifont.ttf uifontb.ttf uifonti.ttf uifontbi.ttf); |
491 | |
893 | |
492 | CFClient::add_font $_ for @fonts; |
894 | CFClient::add_font $_ for @fonts; |
493 | CFClient::set_font $fonts[0]; |
895 | CFClient::set_font $fonts[0]; |
494 | } |
896 | } |
495 | |
897 | |
496 | $FACECACHE = eval { Crossfire::load_ref "$Crossfire::VARDIR/pclient.faces" } || {}; |
898 | video_init; |
|
|
899 | audio_init; |
497 | |
900 | |
498 | Event::loop; |
901 | Event::loop; |
499 | |
902 | |
500 | Crossfire::save_ref $FACECACHE, "$Crossfire::VARDIR/pclient.faces"; |
903 | END { SDL::Quit } |
501 | |
904 | |
|
|
905 | |