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.61 by root, Wed Jul 19 23:00:07 2006 UTC vs.
Revision 1.64 by root, Sun Jul 23 08:58:44 2006 UTC

242 $::STATWIDS->{st_dam} ->set_text (sprintf "%d" , $stats->{+CS_STAT_DAM}); 242 $::STATWIDS->{st_dam} ->set_text (sprintf "%d" , $stats->{+CS_STAT_DAM});
243 $::STATWIDS->{st_arm} ->set_text (sprintf "%d" , $stats->{+CS_STAT_RES_PHYS}); 243 $::STATWIDS->{st_arm} ->set_text (sprintf "%d" , $stats->{+CS_STAT_RES_PHYS});
244 $::STATWIDS->{st_spd} ->set_text (sprintf "%.1f", $stats->{+CS_STAT_SPEED}); 244 $::STATWIDS->{st_spd} ->set_text (sprintf "%.1f", $stats->{+CS_STAT_SPEED});
245 $::STATWIDS->{st_wspd}->set_text (sprintf "%.1f", $stats->{+CS_STAT_WEAP_SP}); 245 $::STATWIDS->{st_wspd}->set_text (sprintf "%.1f", $stats->{+CS_STAT_WEAP_SP});
246 246
247 $::STATWIDS->{m_weight}->set_text (sprintf "Max weight: %.1fkg", $stats->{+CS_STAT_WEIGHT_LIM} / 1000); 247 $self->update_weight;
248 248
249 $::STATWIDS->{"res_$_"}->set_text (sprintf "%d%", $stats->{$RES_TBL{$_}}) 249 $::STATWIDS->{"res_$_"}->set_text (sprintf "%d%", $stats->{$RES_TBL{$_}})
250 for keys %RES_TBL; 250 for keys %RES_TBL;
251 251
252 my $sktbl = $::STATWIDS->{skill_tbl}; 252 my $sktbl = $::STATWIDS->{skill_tbl};
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
711sub update_floorbox { 711sub 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
741sub set_opencont { 747sub 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 {
825 } 832 }
826} 833}
827 834
828sub player_update { 835sub player_update {
829 my ($self, $player) = @_; 836 my ($self, $player) = @_;
837
838 $self->update_weight;
839}
840
841sub update_weight {
842 my ($self) = @_;
843
844 my $weight = .001 * $self->{player}{weight};
845 my $limit = .001 * $self->{stat}{+CS_STAT_WEIGHT_LIM};
846
830 $::STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $player->{weight} / 1000); 847 $::STATWIDS->{weight}->set_text (sprintf "Weight: %.1fkg", $weight);
848 $::STATWIDS->{m_weight}->set_text (sprintf "%.1fkg", $limit);
849 $::STATWIDS->{i_weight}->set_text (sprintf "%.1f/%.1fkg", $weight, $limit);
831} 850}
832 851
833sub update_server_info { 852sub update_server_info {
834 my ($self) = @_; 853 my ($self) = @_;
835 854
905 name => "npc_dialog", 924 name => "npc_dialog",
906 force_w => $::WIDTH * 0.7, 925 force_w => $::WIDTH * 0.7,
907 force_h => $::HEIGHT * 0.7, 926 force_h => $::HEIGHT * 0.7,
908 title => "NPC Dialog", 927 title => "NPC Dialog",
909 kw => { hi => 0, yes => 0, no => 0 }, 928 kw => { hi => 0, yes => 0, no => 0 },
929 has_close_button => 1,
910 @_, 930 @_,
911 ); 931 );
912 932
913 Scalar::Util::weaken (my $this = $self); 933 Scalar::Util::weaken (my $this = $self);
934
935 $self->connect (delete => sub { $this->destroy; 1 });
914 936
915 # better use a pane... 937 # better use a pane...
916 $self->add (my $hbox = new CFClient::UI::HBox); 938 $self->add (my $hbox = new CFClient::UI::HBox);
917 $hbox->add ($self->{textview} = new CFClient::UI::TextScroller expand => 1); 939 $hbox->add ($self->{textview} = new CFClient::UI::TextScroller expand => 1);
918 940
940 $vbox->add ($self->{options} = new CFClient::UI::VBox); 962 $vbox->add ($self->{options} = new CFClient::UI::VBox);
941 963
942 $self->{bye_button} = new CFClient::UI::Button 964 $self->{bye_button} = new CFClient::UI::Button
943 text => "Bye (close)", 965 text => "Bye (close)",
944 tooltip => "Use this button to end talking to the NPC. This also closes the dialog window.", 966 tooltip => "Use this button to end talking to the NPC. This also closes the dialog window.",
945 on_activate => sub { $this->destroy; 0 }, 967 on_activate => sub { $this->destroy; 1 },
946 ; 968 ;
947 969
948 $self->update_options; 970 $self->update_options;
949 971
950 $self->{token} = $self->{conn}->ext_token; 972 $self->{token} = $self->{conn}->ext_token;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines