--- deliantra/Deliantra-Client/DC/Protocol.pm 2006/07/22 12:18:02 1.62 +++ deliantra/Deliantra-Client/DC/Protocol.pm 2006/07/23 16:11:12 1.65 @@ -7,6 +7,7 @@ use CFClient; use CFClient::UI; +use CFClient::Pod; use base 'Crossfire::Protocol::Base'; @@ -17,7 +18,7 @@ $self->{map_widget}->clr_commands; - my $cmd_help = CFClient::load_pod CFClient::find_rcfile "pod/command_help.pod", command_help => 1, sub { + my $cmd_help = CFClient::Pod::load CFClient::find_rcfile "pod/command_help.pod", command_help => 1, sub { my ($pom) = @_; my @cmd_help; @@ -33,7 +34,7 @@ $_ = $_ eq ".*" ? "" : " $_" for @args; - my $text = CFClient::pod_to_pango $head2->content; + my $text = CFClient::Pod::as_xml $head2->content; push @cmd_help, ["$cmd$_", $text] for sort { (length $a) <=> (length $b) } @@ -244,7 +245,7 @@ $::STATWIDS->{st_spd} ->set_text (sprintf "%.1f", $stats->{+CS_STAT_SPEED}); $::STATWIDS->{st_wspd}->set_text (sprintf "%.1f", $stats->{+CS_STAT_WEAP_SP}); - $::STATWIDS->{m_weight}->set_text (sprintf "Max weight: %.1fkg", $stats->{+CS_STAT_WEIGHT_LIM} / 1000); + $self->update_weight; $::STATWIDS->{"res_$_"}->set_text (sprintf "%d%", $stats->{$RES_TBL{$_}}) for keys %RES_TBL; @@ -262,7 +263,7 @@ $sktbl->add (4, 0, new CFClient::UI::Label text => "Lvl.", align => 1); $sktbl->add (5, 0, new CFClient::UI::Label text => "Skill", expand => 1); - my ($x, $y) = (1, 0); + my ($x, $y) = (0, 1); for ( sort { $stats->{$b->[0]}[1] <=> $stats->{$a->[0]}[1] or $a->[1] cmp $b->[1] } map [$_, $self->{skill_info}{$_}], @@ -599,12 +600,12 @@ # try to create single paragraphs of multiple lines sent by the server $text =~ s/(?<=\S)\n(?=\w)/ /g; - $text = CFClient::UI::Label::escape $text; + $text = CFClient::asxml $text; $text =~ s/\[b\](.*?)\[\/b\]/\1<\/b>/g; $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/\2<\/span>/g; $self->{logview}->add_paragraph ($color[$color], $_) - for map "$time $_", split /\n/, $text; + for map "$time $_", split /\n/, $text; $self->{logview}->scroll_to_bottom; $self->{statusbox}->add ($text, @@ -631,8 +632,8 @@ $::SPELL_PAGE->add_spell ($spell); - $self->{map_widget}->add_command ("invoke $spell->{name}", CFClient::UI::Label::escape $spell->{message}); - $self->{map_widget}->add_command ("cast $spell->{name}", CFClient::UI::Label::escape $spell->{message}); + $self->{map_widget}->add_command ("invoke $spell->{name}", CFClient::asxml $spell->{message}); + $self->{map_widget}->add_command ("cast $spell->{name}", CFClient::asxml $spell->{message}); } sub spell_delete { @@ -644,13 +645,13 @@ sub addme_success { my ($self) = @_; - my $skill_help = CFClient::load_pod CFClient::find_rcfile "pod/skill_help.pod", skill_help => 1, sub { + my $skill_help = CFClient::Pod::load CFClient::find_rcfile "pod/skill_help.pod", skill_help => 1, sub { my ($pom) = @_; my %skill_help; for my $head2 ($pom->head1->[3]->head2) { - $skill_help{$head2->title} = CFClient::pod_to_pango $head2->content; + $skill_help{$head2->title} = CFClient::Pod::as_xml $head2->content; } \%skill_help @@ -658,10 +659,10 @@ for my $skill (values %{$self->{skill_info}}) { $self->{map_widget}->add_command ("ready_skill $skill", - (CFClient::UI::Label::escape "Ready the skill '$skill'\n\n") + (CFClient::asxml "Ready the skill '$skill'\n\n") . $skill_help->{$skill}); $self->{map_widget}->add_command ("use_skill $skill", - (CFClient::UI::Label::escape "Immediately use the skill '$skill'\n\n") + (CFClient::asxml "Immediately use the skill '$skill'\n\n") . $skill_help->{$skill}); } } @@ -696,14 +697,14 @@ $self->send ("requestinfo image_sums $face $face"); - $self->{statusbox}->add (CFClient::UI::Label::escape "prefetching $todo", + $self->{statusbox}->add (CFClient::asxml "prefetching $todo", group => "prefetch", timeout => 3, fg => [1, 1, 0, 0.5]); } elsif (!exists $self->{num_faces}) { $self->send ("requestinfo image_info"); $self->{num_faces} = 0; - $self->{statusbox}->add (CFClient::UI::Label::escape "starting to prefetch", + $self->{statusbox}->add (CFClient::asxml "starting to prefetch", group => "prefetch", timeout => 3, fg => [1, 1, 0, 0.5]); } } @@ -834,7 +835,19 @@ sub player_update { my ($self, $player) = @_; - $::STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $player->{weight} / 1000); + + $self->update_weight; +} + +sub update_weight { + my ($self) = @_; + + my $weight = .001 * $self->{player}{weight}; + my $limit = .001 * $self->{stat}{+CS_STAT_WEIGHT_LIM}; + + $::STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $weight); + $::STATWIDS->{m_weight}->set_text (sprintf "%.1fkg", $limit); + $::STATWIDS->{i_weight}->set_text (sprintf "%.1f/%.1fkg", $weight, $limit); } sub update_server_info { @@ -914,11 +927,14 @@ force_h => $::HEIGHT * 0.7, title => "NPC Dialog", kw => { hi => 0, yes => 0, no => 0 }, + has_close_button => 1, @_, ); Scalar::Util::weaken (my $this = $self); + $self->connect (delete => sub { $this->destroy; 1 }); + # better use a pane... $self->add (my $hbox = new CFClient::UI::HBox); $hbox->add ($self->{textview} = new CFClient::UI::TextScroller expand => 1); @@ -949,7 +965,7 @@ $self->{bye_button} = new CFClient::UI::Button text => "Bye (close)", tooltip => "Use this button to end talking to the NPC. This also closes the dialog window.", - on_activate => sub { $this->destroy; 0 }, + on_activate => sub { $this->destroy; 1 }, ; $self->update_options; @@ -999,7 +1015,7 @@ $self->{kw}{$_} = 1 for @kw; - $msg = "\n" . CFClient::UI::Label::escape $msg; + $msg = "\n" . CFClient::UI::asxml $msg; my $match = join "|", map "\\b\Q$_\E\\b", sort { (length $b) <=> (length $a) } keys %{ $self->{kw} }; my @link; $msg =~ s{ @@ -1033,7 +1049,7 @@ sub send { my ($self, $msg) = @_; - $self->{textview}->add_paragraph ([1, 1, 0, 1], "\n" . CFClient::UI::Label::escape $msg); + $self->{textview}->add_paragraph ([1, 1, 0, 1], "\n" . CFClient::asxml $msg); $self->{textview}->scroll_to_bottom; utf8::encode $msg;