… | |
… | |
21 | our $VERSION = '0.1'; |
21 | our $VERSION = '0.1'; |
22 | |
22 | |
23 | my $MAX_FPS = 60; |
23 | my $MAX_FPS = 60; |
24 | my $MIN_FPS = 5; # unused as of yet |
24 | my $MIN_FPS = 5; # unused as of yet |
25 | |
25 | |
|
|
26 | our $META_SERVER = "crossfire.real-time.com:13326"; |
|
|
27 | |
26 | our $FACECACHE; |
28 | our $FACECACHE; |
27 | |
29 | |
28 | our $LAST_REFRESH; |
30 | our $LAST_REFRESH; |
29 | our $NOW; |
31 | our $NOW; |
30 | |
32 | |
… | |
… | |
38 | our $FULLSCREEN; |
40 | our $FULLSCREEN; |
39 | our $FONTSIZE; |
41 | our $FONTSIZE; |
40 | |
42 | |
41 | our $MAP; |
43 | our $MAP; |
42 | our $MAPWIDGET; |
44 | our $MAPWIDGET; |
|
|
45 | our $BUTTONBAR; |
|
|
46 | our $LOGVIEW; |
|
|
47 | our $CONSOLE; |
|
|
48 | our $METASERVER; |
43 | |
49 | |
44 | our $SDL_ACTIVE; |
50 | our $SDL_ACTIVE; |
45 | our $SDL_EV; |
51 | our $SDL_EV; |
46 | our %SDL_CB; |
52 | our %SDL_CB; |
47 | |
53 | |
48 | our $ALT_ENTER_MESSAGE; |
54 | our $ALT_ENTER_MESSAGE; |
49 | our $STATUS_LINE; |
55 | our $STATUS_LINE; |
50 | our $DEBUG_STATUS; |
56 | our $DEBUG_STATUS; |
51 | our $BUTTONBAR; |
|
|
52 | our $LOGVIEW; |
|
|
53 | our $CONSOLE; |
|
|
54 | |
57 | |
55 | sub status { |
58 | sub status { |
56 | $STATUS_LINE->set_text ($_[0]); |
59 | $STATUS_LINE->set_text ($_[0]); |
57 | my ($w, $h) = $STATUS_LINE->size_request; |
60 | my ($w, $h) = $STATUS_LINE->size_request; |
58 | $STATUS_LINE->size_allocate (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $h, $w, $h); |
61 | $STATUS_LINE->size_allocate (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $h, $w, $h); |
… | |
… | |
65 | } |
68 | } |
66 | |
69 | |
67 | sub start_game { |
70 | sub start_game { |
68 | status "logging in..."; |
71 | status "logging in..."; |
69 | |
72 | |
70 | my $mapsize = List::Util::min 64, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; |
73 | my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; |
71 | |
74 | |
72 | $MAP = new CFClient::Map $mapsize, $mapsize; |
75 | $MAP = new CFClient::Map $mapsize, $mapsize; |
|
|
76 | |
|
|
77 | my ($host, $port) = split /:/, $CFG->{host}; |
73 | |
78 | |
74 | $CONN = new conn |
79 | $CONN = new conn |
75 | host => $CFG->{host}, |
80 | host => $host, |
76 | port => $CFG->{port}, |
81 | port => $port || 13327, |
77 | user => $CFG->{user}, |
82 | user => $CFG->{user}, |
78 | pass => $CFG->{password}, |
83 | pass => $CFG->{password}, |
79 | mapw => $mapsize, |
84 | mapw => $mapsize, |
80 | maph => $mapsize, |
85 | maph => $mapsize, |
81 | ; |
86 | ; |
… | |
… | |
87 | |
92 | |
88 | sub stop_game { |
93 | sub stop_game { |
89 | undef $CONN; |
94 | undef $CONN; |
90 | } |
95 | } |
91 | |
96 | |
92 | sub config_dialog { |
97 | sub client_setup { |
93 | my $dialog = new CFClient::UI::FancyFrame |
98 | my $dialog = new CFClient::UI::FancyFrame |
94 | child => (my $vbox = new CFClient::UI::VBox); |
99 | child => (my $vbox = new CFClient::UI::VBox); |
95 | $vbox->add (new CFClient::UI::Label align => 0, text => "Client Setup"); |
100 | $vbox->add (new CFClient::UI::Label align => 0, text => "Client Setup"); |
96 | $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); |
101 | $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); |
97 | |
102 | |
… | |
… | |
137 | $table->add (1, 5, new CFClient::UI::CheckBox state => $CFG->{fow_smooth}, connect_changed => sub { |
142 | $table->add (1, 5, new CFClient::UI::CheckBox state => $CFG->{fow_smooth}, connect_changed => sub { |
138 | my ($self, $value) = @_; |
143 | my ($self, $value) = @_; |
139 | $CFG->{fow_smooth} = $value; |
144 | $CFG->{fow_smooth} = $value; |
140 | }); |
145 | }); |
141 | |
146 | |
|
|
147 | $table->add (0, 6, new CFClient::UI::Label align => 1, text => "Log Fontsize"); |
|
|
148 | $table->add (1, 6, new CFClient::UI::Slider range => [$CFG->{log_fontsize}, 8, 30, 1], connect_changed => sub { |
|
|
149 | my ($self, $value) = @_; |
|
|
150 | $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = int $value); |
|
|
151 | }); |
|
|
152 | |
142 | $table->add (1, 6, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { |
153 | $table->add (1, 7, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { |
143 | destroy_screen (); |
154 | destroy_screen (); |
144 | init_screen (); |
155 | init_screen (); |
145 | }); |
156 | }); |
|
|
157 | |
|
|
158 | $dialog |
|
|
159 | } |
|
|
160 | |
|
|
161 | sub metaserver_dialog { |
|
|
162 | my $dialog = new CFClient::UI::FancyFrame |
|
|
163 | child => (my $vbox = new CFClient::UI::VBox); |
|
|
164 | |
|
|
165 | $vbox->add ($dialog->{table} = new CFClient::UI::Table); |
|
|
166 | |
|
|
167 | $dialog |
|
|
168 | } |
|
|
169 | |
|
|
170 | sub update_metaserver { |
|
|
171 | my ($HOST) = @_; |
|
|
172 | |
|
|
173 | status "fetching metaserver list..."; |
|
|
174 | |
|
|
175 | my $buf; |
|
|
176 | |
|
|
177 | my $fh = new IO::Socket::INET PeerHost => $META_SERVER, Blocking => 0; |
|
|
178 | |
|
|
179 | Event->io (fd => $fh, poll => 'r', cb => sub { |
|
|
180 | my $res = sysread $fh, $buf, 8192, length $buf; |
|
|
181 | |
|
|
182 | if (!defined $res) { |
|
|
183 | $_[0]->w->cancel; |
|
|
184 | status "metaserver: $!"; |
|
|
185 | } elsif ($res == 0) { |
|
|
186 | $_[0]->w->cancel; |
|
|
187 | status "server list retrieved"; |
|
|
188 | |
|
|
189 | my $table = $METASERVER->{table}; |
|
|
190 | |
|
|
191 | $table->clear; |
|
|
192 | |
|
|
193 | my @col = qw(Use #Users Host Uptime Version Description); |
|
|
194 | $table->add ($_, 0, new CFClient::UI::Label align => 0, fg => [1, 1, 0], text => $col[$_]) |
|
|
195 | for 0 .. $#col; |
|
|
196 | |
|
|
197 | my @align = qw(1 0 1 1 -1); |
|
|
198 | |
|
|
199 | my $y = 0; |
|
|
200 | for my $m (sort { $b->[3] <=> $a->[3] } map [split /\|/], split /\015?\012/, $buf) { |
|
|
201 | my ($ip, $last, $host, $users, $version, $desc, $ibytes, $obytes, $uptime) = @$m; |
|
|
202 | |
|
|
203 | for ($desc) { |
|
|
204 | s/<br>/\n/gi; |
|
|
205 | s/<li>/\n· /gi; |
|
|
206 | s/<.*?>//sgi; |
|
|
207 | s/&/&/g; |
|
|
208 | s/</</g; |
|
|
209 | s/>/>/g; |
|
|
210 | } |
|
|
211 | |
|
|
212 | $uptime = sprintf "%dd %02d:%02d:%02d", |
|
|
213 | (int $m->[8] / 86400), |
|
|
214 | (int $m->[8] / 3600) % 24, |
|
|
215 | (int $m->[8] / 60) % 60, |
|
|
216 | $m->[8] % 60; |
|
|
217 | |
|
|
218 | $m = [$users, $host, $uptime, $version, $desc]; |
|
|
219 | |
|
|
220 | $y++; |
|
|
221 | |
|
|
222 | $table->add (0, $y, new CFClient::UI::VBox children => [ |
|
|
223 | (new CFClient::UI::Button text => " ", connect_activate => sub { |
|
|
224 | $HOST->set_text ($CFG->{host} = $host); |
|
|
225 | }), |
|
|
226 | (new CFClient::UI::Empty expand => 1), |
|
|
227 | ]); |
|
|
228 | |
|
|
229 | $table->add ($_ + 1, $y, new CFClient::UI::Label align => $align[$_], text => $m->[$_], fontsize => $FONTSIZE * 0.8) |
|
|
230 | for 0 .. $#$m; |
|
|
231 | } |
|
|
232 | } |
|
|
233 | }); |
|
|
234 | } |
|
|
235 | |
|
|
236 | sub server_setup { |
|
|
237 | my $dialog = new CFClient::UI::FancyFrame |
|
|
238 | child => (my $vbox = new CFClient::UI::VBox); |
146 | |
239 | |
147 | $vbox->add (new CFClient::UI::Label align => 0, text => "Server Setup"); |
240 | $vbox->add (new CFClient::UI::Label align => 0, text => "Server Setup"); |
148 | $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); |
241 | $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); |
149 | $table->add (0, 2, new CFClient::UI::Label align => 1, text => "Host"); |
242 | $table->add (0, 2, new CFClient::UI::Label align => 1, text => "Host:Port"); |
|
|
243 | |
|
|
244 | { |
|
|
245 | $table->add (1, 2, my $vbox = new CFClient::UI::VBox); |
|
|
246 | |
150 | $table->add (1, 2, my $host = new CFClient::UI::Entry text => $CFG->{host}, connect_changed => sub { |
247 | $vbox->add (my $HOST = new CFClient::UI::Entry text => $CFG->{host}, connect_changed => sub { |
151 | my ($self, $value) = @_; |
248 | my ($self, $value) = @_; |
152 | $CFG->{host} = $value; |
249 | $CFG->{host} = $value; |
153 | }); |
250 | }); |
154 | |
251 | |
155 | $table->add (0, 3, new CFClient::UI::Label align => 1, text => "Port"); |
252 | $METASERVER = metaserver_dialog; |
156 | $table->add (1, 3, my $port = new CFClient::UI::Entry text => $CFG->{port}, connect_changed => sub { |
253 | |
157 | my ($self, $value) = @_; |
254 | $vbox->add (new CFClient::UI::Flopper text => "Metaserver", other => $METASERVER, connect_open => sub { |
158 | $CFG->{port} = $value; |
255 | update_metaserver $HOST; |
159 | }); |
256 | }); |
|
|
257 | } |
160 | |
258 | |
161 | $table->add (0, 4, new CFClient::UI::Label align => 1, text => "Username"); |
259 | $table->add (0, 4, new CFClient::UI::Label align => 1, text => "Username"); |
162 | $table->add (1, 4, my $user = new CFClient::UI::Entry text => $CFG->{user}, connect_changed => sub { |
260 | $table->add (1, 4, new CFClient::UI::Entry text => $CFG->{user}, connect_changed => sub { |
163 | my ($self, $value) = @_; |
261 | my ($self, $value) = @_; |
164 | $CFG->{user} = $value; |
262 | $CFG->{user} = $value; |
165 | }); |
263 | }); |
166 | |
264 | |
167 | $table->add (0, 5, new CFClient::UI::Label align => 1, text => "Password"); |
265 | $table->add (0, 5, new CFClient::UI::Label align => 1, text => "Password"); |
168 | $table->add (1, 5, my $pass = new CFClient::UI::Entry text => $CFG->{password}, hidden => 1, connect_changed => sub { |
266 | $table->add (1, 5, new CFClient::UI::Entry text => $CFG->{password}, hidden => 1, connect_changed => sub { |
169 | my ($self, $value) = @_; |
267 | my ($self, $value) = @_; |
170 | $CFG->{password} = $value; |
268 | $CFG->{password} = $value; |
171 | }); |
269 | }); |
172 | |
270 | |
173 | $table->add (0, 6, new CFClient::UI::Label align => 1, text => "Def. say cmd"); |
271 | $table->add (0, 6, new CFClient::UI::Label align => 1, text => "Def. say cmd"); |
… | |
… | |
189 | |
287 | |
190 | $table->add (1, 8, new CFClient::UI::Button expand => 1, align => 0, text => "Login", connect_activate => sub { |
288 | $table->add (1, 8, new CFClient::UI::Button expand => 1, align => 0, text => "Login", connect_activate => sub { |
191 | start_game; |
289 | start_game; |
192 | }); |
290 | }); |
193 | |
291 | |
194 | $vbox->add (my $hbox = new CFClient::UI::HBox); |
|
|
195 | |
|
|
196 | $hbox->add (new CFClient::UI::Button expand => 1, align => 0, text => "Save", connect_activate => sub { |
|
|
197 | CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; |
|
|
198 | status "Configuration Saved"; |
|
|
199 | }); |
|
|
200 | |
|
|
201 | $dialog |
292 | $dialog |
202 | } |
293 | } |
203 | |
294 | |
204 | sub console_window { |
295 | sub message_window { |
205 | my $window = new CFClient::UI::FancyFrame |
296 | my $window = new CFClient::UI::FancyFrame |
206 | border_bg => [1, 1, 1, 0.5], |
297 | border_bg => [1, 1, 1, 0.5], |
207 | bg => [0.3, 0.3, 0.3, 0.8], |
298 | bg => [0.3, 0.3, 0.3, 0.8], |
|
|
299 | user_w => $::WIDTH/4, |
|
|
300 | user_h => $::HEIGHT, |
208 | child => (my $vbox = new CFClient::UI::VBox); |
301 | child => (my $vbox = new CFClient::UI::VBox); |
209 | |
302 | |
210 | $vbox->add ($LOGVIEW = new CFClient::UI::TextView expand => 1); |
303 | $vbox->add ($LOGVIEW = new CFClient::UI::TextView |
|
|
304 | expand => 1, |
|
|
305 | fontsize => $::CFG->{log_fontsize}, |
|
|
306 | ); |
|
|
307 | |
211 | $vbox->add (my $input = new CFClient::UI::LineEntry); |
308 | $vbox->add (my $input = new CFClient::UI::LineEntry); |
212 | $input->connect (activate => sub { |
309 | $input->connect (activate => sub { |
213 | my ($input, $text) = @_; |
310 | my ($input, $text) = @_; |
214 | $input->set_text (''); |
311 | $input->set_text (''); |
215 | |
312 | |
… | |
… | |
233 | |
330 | |
234 | $window |
331 | $window |
235 | } |
332 | } |
236 | |
333 | |
237 | sub sdl_init { |
334 | sub sdl_init { |
|
|
335 | #SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE |
238 | SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO |
336 | SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO |
239 | and die "SDL::Init failed!\n"; |
337 | and die "SDL::Init failed!\n"; |
240 | } |
338 | } |
241 | |
339 | |
242 | sub init_screen { |
340 | sub init_screen { |
… | |
… | |
247 | $FAST = $CFG->{fast}; |
345 | $FAST = $CFG->{fast}; |
248 | |
346 | |
249 | SDL::GLSetAttribute SDL_GL_RED_SIZE, 5; |
347 | SDL::GLSetAttribute SDL_GL_RED_SIZE, 5; |
250 | SDL::GLSetAttribute SDL_GL_GREEN_SIZE, 5; |
348 | SDL::GLSetAttribute SDL_GL_GREEN_SIZE, 5; |
251 | SDL::GLSetAttribute SDL_GL_BLUE_SIZE, 5; |
349 | SDL::GLSetAttribute SDL_GL_BLUE_SIZE, 5; |
252 | SDL::GLSetAttribute SDL_GL_ALPHA_SIZE, 0; |
350 | SDL::GLSetAttribute SDL_GL_ALPHA_SIZE, 1; |
253 | |
351 | |
254 | SDL::GLSetAttribute SDL_GL_ACCUM_RED_SIZE, 0; |
352 | SDL::GLSetAttribute SDL_GL_ACCUM_RED_SIZE, 0; |
255 | SDL::GLSetAttribute SDL_GL_ACCUM_GREEN_SIZE, 0; |
353 | SDL::GLSetAttribute SDL_GL_ACCUM_GREEN_SIZE, 0; |
256 | SDL::GLSetAttribute SDL_GL_ACCUM_BLUE_SIZE, 0; |
354 | SDL::GLSetAttribute SDL_GL_ACCUM_BLUE_SIZE, 0; |
257 | SDL::GLSetAttribute SDL_GL_ACCUM_ALPHA_SIZE, 0; |
355 | SDL::GLSetAttribute SDL_GL_ACCUM_ALPHA_SIZE, 0; |
… | |
… | |
279 | $FONTSIZE = int $HEIGHT / 40; |
377 | $FONTSIZE = int $HEIGHT / 40; |
280 | |
378 | |
281 | ############################################################################# |
379 | ############################################################################# |
282 | |
380 | |
283 | $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100; |
381 | $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100; |
284 | $CFClient::UI::TOPLEVEL->add ($DEBUG_STATUS); |
382 | $CFClient::UI::ROOT->add ($DEBUG_STATUS); |
285 | |
383 | |
286 | $STATUS_LINE = new CFClient::UI::Label |
384 | $STATUS_LINE = new CFClient::UI::Label |
287 | padding => 0, |
385 | padding => 0, |
288 | y => $HEIGHT * 44 / 45 - $FONTSIZE; |
386 | y => $HEIGHT * 44 / 45 - $FONTSIZE; |
289 | $CFClient::UI::TOPLEVEL->add ($STATUS_LINE); |
387 | $CFClient::UI::ROOT->add ($STATUS_LINE); |
290 | |
388 | |
291 | $ALT_ENTER_MESSAGE = new CFClient::UI::Label |
389 | $ALT_ENTER_MESSAGE = new CFClient::UI::Label |
292 | padding => 0, |
390 | padding => 0, |
293 | y => $HEIGHT * 44 / 45, |
391 | y => $HEIGHT * 44 / 45, |
294 | height => $HEIGHT / 45, |
392 | height => $HEIGHT / 45, |
295 | text => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; |
393 | text => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; |
296 | $CFClient::UI::TOPLEVEL->add ($ALT_ENTER_MESSAGE); |
394 | $CFClient::UI::ROOT->add ($ALT_ENTER_MESSAGE); |
297 | |
395 | |
298 | $CFClient::UI::TOPLEVEL->add ($MAPWIDGET = new CFClient::UI::MapWidget); |
396 | $CFClient::UI::ROOT->add ($MAPWIDGET = new CFClient::UI::MapWidget); |
299 | $MAPWIDGET->focus_in; |
397 | $MAPWIDGET->focus_in; |
300 | $MAPWIDGET->connect (activate_console => sub { |
398 | $MAPWIDGET->connect (activate_console => sub { |
301 | my ($mapwidget, $preset) = @_; |
399 | my ($mapwidget, $preset) = @_; |
302 | |
400 | |
303 | if ($CONSOLE) { |
401 | if ($CONSOLE) { |
… | |
… | |
307 | $CONSOLE->{input}->set_text ($preset); |
405 | $CONSOLE->{input}->set_text ($preset); |
308 | } |
406 | } |
309 | } |
407 | } |
310 | }); |
408 | }); |
311 | |
409 | |
312 | $CFClient::UI::TOPLEVEL->add ($BUTTONBAR = new CFClient::UI::HBox); |
410 | $CFClient::UI::ROOT->add ($BUTTONBAR = new CFClient::UI::HBox); |
313 | |
411 | |
314 | $BUTTONBAR->add (my $setup = new CFClient::UI::Flopper x => 0, y => 0, text => "Setup", other => config_dialog, state => 1); |
412 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Client Setup", other => client_setup); |
315 | $BUTTONBAR->add (my $setup = new CFClient::UI::Flopper x => 0, y => 0, text => "Console", other => console_window); |
413 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Server Setup", other => server_setup); |
|
|
414 | $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => message_window); |
|
|
415 | |
|
|
416 | $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", connect_activate => sub { |
|
|
417 | CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; |
|
|
418 | status "Configuration Saved"; |
|
|
419 | }); |
|
|
420 | |
|
|
421 | $BUTTONBAR->{children}[0]->emit ("activate"); |
316 | } |
422 | } |
317 | |
423 | |
318 | sub destroy_screen { |
424 | sub destroy_screen { |
319 | $CFClient::UI::TOPLEVEL->{children} = []; |
425 | $CFClient::UI::ROOT->{children} = []; |
320 | undef $SDL_ACTIVE; |
426 | undef $SDL_ACTIVE; |
321 | undef $SDL_EV; |
427 | undef $SDL_EV; |
322 | SDL::Quit; |
428 | SDL::Quit; |
323 | } |
429 | } |
324 | |
430 | |
… | |
… | |
335 | debug sprintf "%3.2f", $fps; |
441 | debug sprintf "%3.2f", $fps; |
336 | |
442 | |
337 | $want_refresh = 0; |
443 | $want_refresh = 0; |
338 | $can_refresh = 0; |
444 | $can_refresh = 0; |
339 | |
445 | |
340 | glViewport 0, 0, $WIDTH, $HEIGHT; |
|
|
341 | glClearColor +($CFG->{fow_intensity}) x 3, 1; |
|
|
342 | glClear GL_COLOR_BUFFER_BIT; |
|
|
343 | |
|
|
344 | glMatrixMode GL_PROJECTION; |
|
|
345 | glLoadIdentity; |
|
|
346 | glOrtho 0, $WIDTH, $HEIGHT, 0, -10000 , 10000; |
|
|
347 | glMatrixMode GL_MODELVIEW; |
|
|
348 | glLoadIdentity; |
|
|
349 | |
|
|
350 | $CFClient::UI::TOPLEVEL->draw; |
446 | $CFClient::UI::ROOT->draw; |
351 | |
447 | |
352 | SDL::GLSwapBuffers; |
448 | SDL::GLSwapBuffers; |
353 | |
449 | |
354 | $LAST_REFRESH = $NOW; |
450 | $LAST_REFRESH = $NOW; |
355 | } |
451 | } |
… | |
… | |
420 | } |
516 | } |
421 | |
517 | |
422 | sub conn::face_find { |
518 | sub conn::face_find { |
423 | my ($self, $face) = @_; |
519 | my ($self, $face) = @_; |
424 | |
520 | |
|
|
521 | my $data; |
|
|
522 | |
425 | $FACECACHE->{"$face->{chksum},$face->{name}"} |
523 | $FACECACHE->get ("$face->{chksum},$face->{name}") |
426 | } |
524 | } |
427 | |
525 | |
428 | sub conn::face_update { |
526 | sub conn::face_update { |
429 | my ($self, $facenum, $face) = @_; |
527 | my ($self, $facenum, $face) = @_; |
430 | |
528 | |
431 | $FACECACHE->{"$face->{chksum},$face->{name}"} = $face->{image}; |
529 | $FACECACHE->put ("$face->{chksum},$face->{name}" => $face->{image}); |
432 | |
530 | |
433 | my $tex = $face->{texture} = new_from_image CFClient::Texture delete $face->{image}; |
531 | my $tex = $face->{texture} = |
|
|
532 | new_from_image CFClient::Texture |
|
|
533 | delete $face->{image}, minify => 1; |
434 | |
534 | |
435 | $MAP->set_texture ($facenum, @$tex{qw(name w h s t)}); |
535 | $MAP->set_texture ($facenum, @$tex{qw(name w h s t)}, @{$tex->{minified}}); |
436 | $MAPWIDGET->update; |
536 | $MAPWIDGET->update; |
437 | } |
537 | } |
438 | |
538 | |
439 | sub conn::query { |
539 | sub conn::query { |
440 | my ($self, $flags, $prompt) = @_; |
540 | my ($self, $flags, $prompt) = @_; |
… | |
… | |
501 | }, |
601 | }, |
502 | ); |
602 | ); |
503 | |
603 | |
504 | ############################################################################# |
604 | ############################################################################# |
505 | |
605 | |
|
|
606 | $FACECACHE = CFClient::db_table "facecache"; |
|
|
607 | |
506 | CFClient::read_cfg "$Crossfire::VARDIR/pclientrc"; |
608 | CFClient::read_cfg "$Crossfire::VARDIR/pclientrc"; |
507 | |
609 | |
508 | my %DEF_CFG = ( |
610 | my %DEF_CFG = ( |
|
|
611 | sdl_mode => 0, |
509 | width => 640, |
612 | width => 640, |
510 | height => 480, |
613 | height => 480, |
|
|
614 | fullscreen => 0, |
511 | fast => 0, |
615 | fast => 0, |
512 | fow_enable => 1, |
616 | fow_enable => 1, |
513 | fow_intensity => 0.45, |
617 | fow_intensity => 0.45, |
514 | fow_smooth => 0, |
618 | fow_smooth => 0, |
515 | fullscreen => 0, |
619 | log_fontsize => 14, |
516 | sdl_mode => 0, |
|
|
517 | mapsize => 100, |
620 | mapsize => 100, |
518 | host => "crossfire.schmorp.de", |
621 | host => "crossfire.schmorp.de", |
519 | port => 13327, |
|
|
520 | say_command => 'say', |
622 | say_command => 'say', |
521 | ); |
623 | ); |
522 | |
624 | |
523 | while (my ($k, $v) = each %DEF_CFG) { |
625 | while (my ($k, $v) = each %DEF_CFG) { |
524 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
626 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
… | |
… | |
542 | |
644 | |
543 | CFClient::add_font $_ for @fonts; |
645 | CFClient::add_font $_ for @fonts; |
544 | CFClient::set_font $fonts[0]; |
646 | CFClient::set_font $fonts[0]; |
545 | } |
647 | } |
546 | |
648 | |
547 | $FACECACHE = eval { Crossfire::load_ref "$Crossfire::VARDIR/pclient.faces" } || {}; |
|
|
548 | |
|
|
549 | Event::loop; |
649 | Event::loop; |
550 | |
650 | |
551 | Crossfire::save_ref $FACECACHE, "$Crossfire::VARDIR/pclient.faces"; |
|
|
552 | |
651 | |