… | |
… | |
166 | |
166 | |
167 | $dialog |
167 | $dialog |
168 | } |
168 | } |
169 | |
169 | |
170 | sub update_metaserver { |
170 | sub update_metaserver { |
|
|
171 | my ($HOST) = @_; |
|
|
172 | |
171 | status "fetching metaserver list..."; |
173 | status "fetching metaserver list..."; |
172 | |
174 | |
173 | my $buf; |
175 | my $buf; |
174 | |
176 | |
175 | my $fh = new IO::Socket::INET PeerHost => $META_SERVER, Blocking => 0; |
177 | my $fh = new IO::Socket::INET PeerHost => $META_SERVER, Blocking => 0; |
… | |
… | |
186 | |
188 | |
187 | my $table = $METASERVER->{table}; |
189 | my $table = $METASERVER->{table}; |
188 | |
190 | |
189 | $table->clear; |
191 | $table->clear; |
190 | |
192 | |
191 | my @col = qw(#Users Host Uptime Version Description); |
193 | my @col = qw(Use #Users Host Uptime Version Description); |
192 | $table->add ($_, 0, new CFClient::UI::Label align => 0, fg => [1, 1, 0], text => $col[$_]) |
194 | $table->add ($_, 0, new CFClient::UI::Label align => 0, fg => [1, 1, 0], text => $col[$_]) |
193 | for 0 .. $#col; |
195 | for 0 .. $#col; |
194 | |
196 | |
195 | my @align = qw(1 0 1 1 -1); |
197 | my @align = qw(1 0 1 1 -1); |
196 | |
198 | |
197 | my $y = 0; |
199 | my $y = 0; |
198 | for my $m (map [split /\|/], split /\015?\012/, $buf) { |
200 | for my $m (sort { $b->[3] <=> $a->[3] } map [split /\|/], split /\015?\012/, $buf) { |
199 | my ($ip, $last, $host, $users, $version, $desc, $ibytes, $obytes, $uptime) = @$m; |
201 | my ($ip, $last, $host, $users, $version, $desc, $ibytes, $obytes, $uptime) = @$m; |
200 | |
202 | |
201 | for ($desc) { |
203 | for ($desc) { |
202 | s/<br>/\n/gi; |
204 | s/<br>/\n/gi; |
203 | s/<li>/\n· /gi; |
205 | s/<li>/\n· /gi; |
… | |
… | |
214 | $m->[8] % 60; |
216 | $m->[8] % 60; |
215 | |
217 | |
216 | $m = [$users, $host, $uptime, $version, $desc]; |
218 | $m = [$users, $host, $uptime, $version, $desc]; |
217 | |
219 | |
218 | $y++; |
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 | |
219 | $table->add ($_, $y, new CFClient::UI::Label align => $align[$_], text => $m->[$_], fontsize => $FONTSIZE * 0.8) |
229 | $table->add ($_ + 1, $y, new CFClient::UI::Label align => $align[$_], text => $m->[$_], fontsize => $FONTSIZE * 0.8) |
220 | for 0 .. $#$m; |
230 | for 0 .. $#$m; |
221 | } |
231 | } |
222 | } |
232 | } |
223 | }); |
233 | }); |
224 | } |
234 | } |
… | |
… | |
232 | $table->add (0, 2, new CFClient::UI::Label align => 1, text => "Host:Port"); |
242 | $table->add (0, 2, new CFClient::UI::Label align => 1, text => "Host:Port"); |
233 | |
243 | |
234 | { |
244 | { |
235 | $table->add (1, 2, my $vbox = new CFClient::UI::VBox); |
245 | $table->add (1, 2, my $vbox = new CFClient::UI::VBox); |
236 | |
246 | |
237 | $vbox->add (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 { |
238 | my ($self, $value) = @_; |
248 | my ($self, $value) = @_; |
239 | $CFG->{host} = $value; |
249 | $CFG->{host} = $value; |
240 | }); |
250 | }); |
241 | |
251 | |
242 | $METASERVER = metaserver_dialog; |
252 | $METASERVER = metaserver_dialog; |
243 | |
253 | |
244 | $vbox->add (new CFClient::UI::Flopper text => "Metaserver", other => $METASERVER, connect_open => sub { |
254 | $vbox->add (new CFClient::UI::Flopper text => "Metaserver", other => $METASERVER, connect_open => sub { |
245 | update_metaserver; |
255 | update_metaserver $HOST; |
246 | }); |
256 | }); |
247 | } |
257 | } |
248 | |
258 | |
249 | $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"); |
250 | $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 { |
251 | my ($self, $value) = @_; |
261 | my ($self, $value) = @_; |
252 | $CFG->{user} = $value; |
262 | $CFG->{user} = $value; |
253 | }); |
263 | }); |
254 | |
264 | |
255 | $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"); |
256 | $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 { |
257 | my ($self, $value) = @_; |
267 | my ($self, $value) = @_; |
258 | $CFG->{password} = $value; |
268 | $CFG->{password} = $value; |
259 | }); |
269 | }); |
260 | |
270 | |
261 | $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"); |
… | |
… | |
335 | $FAST = $CFG->{fast}; |
345 | $FAST = $CFG->{fast}; |
336 | |
346 | |
337 | SDL::GLSetAttribute SDL_GL_RED_SIZE, 5; |
347 | SDL::GLSetAttribute SDL_GL_RED_SIZE, 5; |
338 | SDL::GLSetAttribute SDL_GL_GREEN_SIZE, 5; |
348 | SDL::GLSetAttribute SDL_GL_GREEN_SIZE, 5; |
339 | SDL::GLSetAttribute SDL_GL_BLUE_SIZE, 5; |
349 | SDL::GLSetAttribute SDL_GL_BLUE_SIZE, 5; |
340 | SDL::GLSetAttribute SDL_GL_ALPHA_SIZE, 0; |
350 | SDL::GLSetAttribute SDL_GL_ALPHA_SIZE, 1; |
341 | |
351 | |
342 | SDL::GLSetAttribute SDL_GL_ACCUM_RED_SIZE, 0; |
352 | SDL::GLSetAttribute SDL_GL_ACCUM_RED_SIZE, 0; |
343 | SDL::GLSetAttribute SDL_GL_ACCUM_GREEN_SIZE, 0; |
353 | SDL::GLSetAttribute SDL_GL_ACCUM_GREEN_SIZE, 0; |
344 | SDL::GLSetAttribute SDL_GL_ACCUM_BLUE_SIZE, 0; |
354 | SDL::GLSetAttribute SDL_GL_ACCUM_BLUE_SIZE, 0; |
345 | SDL::GLSetAttribute SDL_GL_ACCUM_ALPHA_SIZE, 0; |
355 | SDL::GLSetAttribute SDL_GL_ACCUM_ALPHA_SIZE, 0; |
… | |
… | |
506 | } |
516 | } |
507 | |
517 | |
508 | sub conn::face_find { |
518 | sub conn::face_find { |
509 | my ($self, $face) = @_; |
519 | my ($self, $face) = @_; |
510 | |
520 | |
|
|
521 | my $data; |
|
|
522 | |
511 | $FACECACHE->{"$face->{chksum},$face->{name}"} |
523 | $FACECACHE->get ("$face->{chksum},$face->{name}") |
512 | } |
524 | } |
513 | |
525 | |
514 | sub conn::face_update { |
526 | sub conn::face_update { |
515 | my ($self, $facenum, $face) = @_; |
527 | my ($self, $facenum, $face) = @_; |
516 | |
528 | |
517 | $FACECACHE->{"$face->{chksum},$face->{name}"} = $face->{image}; |
529 | $FACECACHE->put ("$face->{chksum},$face->{name}" => $face->{image}); |
518 | |
530 | |
519 | my $tex = $face->{texture} = |
531 | my $tex = $face->{texture} = |
520 | new_from_image CFClient::Texture |
532 | new_from_image CFClient::Texture |
521 | delete $face->{image}, minify => 1; |
533 | delete $face->{image}, minify => 1; |
522 | |
534 | |
… | |
… | |
589 | }, |
601 | }, |
590 | ); |
602 | ); |
591 | |
603 | |
592 | ############################################################################# |
604 | ############################################################################# |
593 | |
605 | |
|
|
606 | $FACECACHE = CFClient::db_table "facecache"; |
|
|
607 | |
594 | CFClient::read_cfg "$Crossfire::VARDIR/pclientrc"; |
608 | CFClient::read_cfg "$Crossfire::VARDIR/pclientrc"; |
595 | |
609 | |
596 | my %DEF_CFG = ( |
610 | my %DEF_CFG = ( |
597 | sdl_mode => 0, |
611 | sdl_mode => 0, |
598 | width => 640, |
612 | width => 640, |
… | |
… | |
630 | |
644 | |
631 | CFClient::add_font $_ for @fonts; |
645 | CFClient::add_font $_ for @fonts; |
632 | CFClient::set_font $fonts[0]; |
646 | CFClient::set_font $fonts[0]; |
633 | } |
647 | } |
634 | |
648 | |
635 | $FACECACHE = eval { Crossfire::load_ref "$Crossfire::VARDIR/pclient.faces" } || {}; |
|
|
636 | |
|
|
637 | Event::loop; |
649 | Event::loop; |
638 | |
650 | |
639 | Crossfire::save_ref $FACECACHE, "$Crossfire::VARDIR/pclient.faces"; |
|
|
640 | |
651 | |