… | |
… | |
585 | [0.11, 0.56, 1.00], |
585 | [0.11, 0.56, 1.00], |
586 | [0.93, 0.46, 0.00], |
586 | [0.93, 0.46, 0.00], |
587 | [0.18, 0.54, 0.34], |
587 | [0.18, 0.54, 0.34], |
588 | [0.56, 0.73, 0.56], |
588 | [0.56, 0.73, 0.56], |
589 | [0.80, 0.80, 0.80], |
589 | [0.80, 0.80, 0.80], |
590 | [0.55, 0.41, 0.13], |
590 | [0.75, 0.61, 0.20], |
591 | [0.99, 0.77, 0.26], |
591 | [0.99, 0.77, 0.26], |
592 | [0.74, 0.65, 0.41], |
592 | [0.74, 0.65, 0.41], |
593 | ); |
593 | ); |
594 | |
594 | |
595 | $self->logprint ("info: ", $text); |
595 | $self->logprint ("info: ", $text); |
… | |
… | |
602 | $text = CFClient::UI::Label::escape $text; |
602 | $text = CFClient::UI::Label::escape $text; |
603 | $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g; |
603 | $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g; |
604 | $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g; |
604 | $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g; |
605 | |
605 | |
606 | $self->{logview}->add_paragraph ($color[$color], $_) |
606 | $self->{logview}->add_paragraph ($color[$color], $_) |
607 | for map "$time $_", split /\n/, $text; |
607 | for map "<span foreground='#ffffff'>$time</span> $_", split /\n/, $text; |
608 | $self->{logview}->scroll_to_bottom; |
608 | $self->{logview}->scroll_to_bottom; |
609 | |
609 | |
610 | $self->{statusbox}->add ($text, |
610 | $self->{statusbox}->add ($text, |
611 | group => $text, |
611 | group => $text, |
612 | fg => $color[$color], |
612 | fg => $color[$color], |
… | |
… | |
709 | } |
709 | } |
710 | |
710 | |
711 | sub update_floorbox { |
711 | sub update_floorbox { |
712 | $CFClient::UI::ROOT->on_refresh ($::FLOORBOX => sub { |
712 | $CFClient::UI::ROOT->on_refresh ($::FLOORBOX => sub { |
713 | return unless $::CONN; |
713 | return unless $::CONN; |
714 | |
714 | |
715 | $::FLOORBOX->clear; |
715 | $::FLOORBOX->clear; |
716 | |
716 | |
717 | my $row; |
717 | my $row; |
718 | for (sort { $a->{count} <=> $b->{count} } values %{ $::CONN->{container}{0} }) { |
718 | for (sort { $a->{count} <=> $b->{count} } values %{ $::CONN->{container}{$::CONN->{open_container} || 0} }) { |
719 | if ($row < 6) { |
719 | if ($row < 6) { |
720 | local $_->{face_widget}; # hack to force recreation of widget |
720 | local $_->{face_widget}; # hack to force recreation of widget |
721 | local $_->{desc_widget}; # hack to force recreation of widget |
721 | local $_->{desc_widget}; # hack to force recreation of widget |
722 | CFClient::Item::update_widgets $_; |
722 | CFClient::Item::update_widgets $_; |
723 | |
723 | |
… | |
… | |
731 | on_activate => sub { ::toggle_player_page ($::INVENTORY_PAGE); 0 }, |
731 | on_activate => sub { ::toggle_player_page ($::INVENTORY_PAGE); 0 }, |
732 | ); |
732 | ); |
733 | last; |
733 | last; |
734 | } |
734 | } |
735 | } |
735 | } |
|
|
736 | if ($::CONN->{open_container}) { |
|
|
737 | $::FLOORBOX->add (1, $row++, new CFClient::UI::Button |
|
|
738 | text => "Close container", |
|
|
739 | on_activate => sub { $::CONN->send ("apply $::CONN->{open_container}") } |
|
|
740 | ); |
|
|
741 | } |
736 | }); |
742 | }); |
737 | |
743 | |
738 | $::WANT_REFRESH++; |
744 | $::WANT_REFRESH++; |
739 | } |
745 | } |
740 | |
746 | |
741 | sub set_opencont { |
747 | sub set_opencont { |
742 | my ($conn, $tag, $name) = @_; |
748 | my ($conn, $tag, $name) = @_; |
743 | $conn->{open_container} = $tag; |
749 | $conn->{open_container} = $tag; |
|
|
750 | update_floorbox; |
744 | |
751 | |
745 | $::INV_RIGHT_HB->clear (); |
752 | $::INV_RIGHT_HB->clear (); |
746 | $::INV_RIGHT_HB->add (new CFClient::UI::Label align => 0, expand => 1, text => $name); |
753 | $::INV_RIGHT_HB->add (new CFClient::UI::Label align => 0, expand => 1, text => $name); |
747 | |
754 | |
748 | if ($tag != 0) { # Floor isn't closable, is it? |
755 | if ($tag != 0) { # Floor isn't closable, is it? |
… | |
… | |
767 | $CFClient::UI::ROOT->on_refresh ("update_containers_$self" => sub { |
774 | $CFClient::UI::ROOT->on_refresh ("update_containers_$self" => sub { |
768 | my $todo = delete $self->{update_container} |
775 | my $todo = delete $self->{update_container} |
769 | or return; |
776 | or return; |
770 | |
777 | |
771 | for my $tag (keys %$todo) { |
778 | for my $tag (keys %$todo) { |
|
|
779 | update_floorbox if $tag == 0 or $tag == $self->{open_container}; |
772 | if ($tag == 0) { |
780 | if ($tag == 0) { |
773 | update_floorbox; |
|
|
774 | $::INVR->set_items ($self->{container}{0}) |
781 | $::INVR->set_items ($self->{container}{0}) |
775 | if $tag == $self->{open_container}; |
782 | if $tag == $self->{open_container}; |
776 | } elsif ($tag == $self->{player}{tag}) { |
783 | } elsif ($tag == $self->{player}{tag}) { |
777 | $::INV->set_items ($self->{container}{$tag}) |
784 | $::INV->set_items ($self->{container}{$tag}) |
778 | } else { |
785 | } else { |
… | |
… | |
985 | |
992 | |
986 | my ($type, $msg) = split / /, $data, 2; |
993 | my ($type, $msg) = split / /, $data, 2; |
987 | |
994 | |
988 | if ($type eq "msg") { |
995 | if ($type eq "msg") { |
989 | my ($msg, @kw) = split /\x00/, $msg; |
996 | my ($msg, @kw) = split /\x00/, $msg; |
|
|
997 | |
|
|
998 | utf8::decode $_ for ($msg, @kw); |
|
|
999 | |
990 | $self->{kw}{$_} = 1 for @kw; |
1000 | $self->{kw}{$_} = 1 for @kw; |
991 | |
1001 | |
992 | $msg = "\n" . CFClient::UI::Label::escape $msg; |
1002 | $msg = "\n" . CFClient::UI::Label::escape $msg; |
993 | my $match = join "|", map "\\b\Q$_\E\\b", sort { (length $b) <=> (length $a) } keys %{ $self->{kw} }; |
1003 | my $match = join "|", map "\\b\Q$_\E\\b", sort { (length $b) <=> (length $a) } keys %{ $self->{kw} }; |
994 | my @link; |
1004 | my @link; |
… | |
… | |
1021 | } |
1031 | } |
1022 | |
1032 | |
1023 | sub send { |
1033 | sub send { |
1024 | my ($self, $msg) = @_; |
1034 | my ($self, $msg) = @_; |
1025 | |
1035 | |
1026 | $self->{conn}->send ("ext npc_dialog_tell $self->{token} $msg"); |
|
|
1027 | $self->{textview}->add_paragraph ([1, 1, 0, 1], "\n" . CFClient::UI::Label::escape $msg); |
1036 | $self->{textview}->add_paragraph ([1, 1, 0, 1], "\n" . CFClient::UI::Label::escape $msg); |
1028 | $self->{textview}->scroll_to_bottom; |
1037 | $self->{textview}->scroll_to_bottom; |
|
|
1038 | |
|
|
1039 | utf8::encode $msg; |
|
|
1040 | $self->{conn}->send ("ext npc_dialog_tell $self->{token} $msg"); |
1029 | } |
1041 | } |
1030 | |
1042 | |
1031 | sub destroy { |
1043 | sub destroy { |
1032 | my ($self) = @_; |
1044 | my ($self) = @_; |
1033 | |
1045 | |