ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/Protocol.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/Protocol.pm (file contents):
Revision 1.21 by root, Mon Jun 5 21:10:04 2006 UTC vs.
Revision 1.30 by root, Sun Jun 11 18:41:30 2006 UTC

347 my ($self, $flags, $prompt) = @_; 347 my ($self, $flags, $prompt) = @_;
348 348
349 $prompt = $LAST_QUERY unless length $prompt; 349 $prompt = $LAST_QUERY unless length $prompt;
350 $LAST_QUERY = $prompt; 350 $LAST_QUERY = $prompt;
351 351
352 my $dialog = new CFClient::UI::FancyFrame 352 $self->{query}-> ($self, $flags, $prompt);
353 x => "center",
354 y => "center",
355 title => "Query",
356 child => my $vbox = new CFClient::UI::VBox,
357 ;
358
359 $vbox->add (new CFClient::UI::Label
360 max_w => $::WIDTH * 0.4,
361 ellipsise => 0,
362 text => $prompt);
363
364 if ($flags & CS_QUERY_YESNO) {
365 $vbox->add (my $hbox = new CFClient::UI::HBox);
366 $hbox->add (new CFClient::UI::Button
367 text => "No",
368 on_activate => sub {
369 $self->send ("reply n");
370 $dialog->destroy;
371 $self->{map_widget}->focus_in;
372 }
373 );
374 $hbox->add (new CFClient::UI::Button
375 text => "Yes",
376 on_activate => sub {
377 $self->send ("reply y");
378 $dialog->destroy;
379 },
380 );
381
382 $dialog->focus_in;
383
384 } elsif ($flags & CS_QUERY_SINGLECHAR) {
385 $dialog->{tooltip} = "Press a key (click on the entry to make sure it has keyboard focus)";
386 $vbox->add (my $entry = new CFClient::UI::Entry
387 on_changed => sub {
388 $self->send ("reply $_[1]");
389 $dialog->destroy;
390 },
391 );
392
393 $entry->focus_in;
394
395 } else {
396 $dialog->{tooltip} = "Enter the reply and press return (click on the entry to make sure it has keyboard focus)";
397
398 $vbox->add (my $entry = new CFClient::UI::Entry
399 $flags & CS_QUERY_HIDEINPUT ? (hiddenchar => "*") : (),
400 on_activate => sub {
401 $self->send ("reply $_[1]");
402 $dialog->destroy;
403 },
404 );
405
406 $entry->focus_in;
407 }
408
409 $dialog->show;
410} 353}
411 354
412sub drawinfo { 355sub drawinfo {
413 my ($self, $color, $text) = @_; 356 my ($self, $color, $text) = @_;
414 357
428 [0.74, 0.65, 0.41], 371 [0.74, 0.65, 0.41],
429 ); 372 );
430 373
431 my $time = sprintf "%02d:%02d:%02d", (localtime time)[2,1,0]; 374 my $time = sprintf "%02d:%02d:%02d", (localtime time)[2,1,0];
432 375
376 # try to create single paragraphs of multiple lines sent by the server
377 $text =~ s/(?<=\S)\n(?=\w)/ /g;
378
433 $text = CFClient::UI::Label::escape $text; 379 $text = CFClient::UI::Label::escape $text;
434 $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g; 380 $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g;
435 $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g; 381 $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g;
436 382
437 $self->{logview}->add_paragraph ($color[$color], 383 $self->{logview}->add_paragraph ($color[$color],
452} 398}
453 399
454sub spell_add { 400sub spell_add {
455 my ($self, $spell) = @_; 401 my ($self, $spell) = @_;
456 402
457 # TODO 403 # try to create single paragraphs of multiple lines sent by the server
458 # create a widget dynamically, using spell face (CF::Protocol downloads them) 404 $spell->{message} =~ s/(?<=\S)\n(?=\w)/ /g;
405 $spell->{message} =~ s/\n+$//;
406 $spell->{message} ||= "Server did not provide a description for this spell.";
407
459 $::SETUP_SPELLS->add_spell ($spell); 408 $::SETUP_SPELLS->add_spell ($spell);
460 409
461 $self->{map_widget}->add_command ("invoke $spell->{name}", CFClient::UI::Label::escape $spell->{message}); 410 $self->{map_widget}->add_command ("invoke $spell->{name}", CFClient::UI::Label::escape $spell->{message});
462 $self->{map_widget}->add_command ("cast $spell->{name}", CFClient::UI::Label::escape $spell->{message}); 411 $self->{map_widget}->add_command ("cast $spell->{name}", CFClient::UI::Label::escape $spell->{message});
463} 412}
540 489
541 $::FLOORBOX->clear; 490 $::FLOORBOX->clear;
542 491
543 my $row; 492 my $row;
544 for (@{ $::CONN->{container}{0} }) { 493 for (@{ $::CONN->{container}{0} }) {
545 if ($row < 7) { 494 if ($row < 6) {
546 local $_->{face_widget}; # hack to force recreation of widget 495 local $_->{face_widget}; # hack to force recreation of widget
547 local $_->{desc_widget}; # hack to force recreation of widget 496 local $_->{desc_widget}; # hack to force recreation of widget
548 CFClient::Item::update_widgets $_; 497 CFClient::Item::update_widgets $_;
549 498
550 $::FLOORBOX->add (0, $row, $_->{face_widget}); 499 $::FLOORBOX->add (0, $row, $_->{face_widget});
551 $::FLOORBOX->add (1, $row, $_->{desc_widget}); 500 $::FLOORBOX->add (1, $row, $_->{desc_widget});
552 501
553 $row++; 502 $row++;
554 } else { 503 } else {
555 $::FLOORBOX->add (1, $row, new CFClient::UI::Label text => "More..."); 504 $::FLOORBOX->add (1, $row, new CFClient::UI::Button
505 text => "More...",
506 on_activate => sub { $::INV_WINDOW->toggle_visibility },
507 );
556 last; 508 last;
557 } 509 }
558 } 510 }
559 }); 511 });
560 512
669 } 621 }
670} 622}
671 623
672sub player_update { 624sub player_update {
673 my ($self, $player) = @_; 625 my ($self, $player) = @_;
626
674 $::STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $player->{weight} / 1000); 627 $::STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $player->{weight} / 1000);
628}
675 629
676 # do it here because it is ignored earlier, and there is no "login" event 630sub logged_in {
631 my ($self) = @_;
632
633 $self->send_ext_req (cfplus => "version", "1", sub {
634 $self->{cfplus_ext} = $_[0];
635 });
636
677 $self->send_command ("output-sync $::CFG->{output_sync}"); 637 $self->send_command ("output-sync $::CFG->{output_sync}");
678 $self->send_command ("output-count $::CFG->{output_count}"); 638 $self->send_command ("output-count $::CFG->{output_count}");
639 $self->send_command ("pickup $::CFG->{pickup}");
640
641 my @yesno = ("<span foreground='red'>no</span>", "<span foreground='green'>yes</span>");
642
643 $::SERVER_INFO->set_markup (
644 "server <tt>$self->{host}:$self->{port}</tt>\n"
645 . "protocol version <tt>$self->{version}</tt>\n"
646 . "minimap support $yesno[$self->{setup}{mapinfocmd} > 0]\n"
647 . "extended command support $yesno[$self->{setup}{extcmd} > 0]\n"
648 . "cfplus support $yesno[$self->{cfplus_ext} > 0]\n"
649 . "map size $self->{mapw}×$self->{maph}\n"
650 );
679} 651}
680 652
6811; 6531;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines