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.201 by root, Wed Sep 3 06:35:55 2008 UTC vs.
Revision 1.206 by elmex, Sun Dec 7 16:20:44 2008 UTC

17our $TEX_DIALOGUE = new_from_resource DC::Texture 17our $TEX_DIALOGUE = new_from_resource DC::Texture
18 "dialogue.png", minify => 1, mipmap => 1; 18 "dialogue.png", minify => 1, mipmap => 1;
19 19
20our $TEX_NOFACE = new_from_resource DC::Texture 20our $TEX_NOFACE = new_from_resource DC::Texture
21 "noface.png", minify => 1, mipmap => 1; 21 "noface.png", minify => 1, mipmap => 1;
22
23sub MIN_TEXTURE_UNUSED() { 1 }#d#
22 24
23sub new { 25sub new {
24 my ($class, %arg) = @_; 26 my ($class, %arg) = @_;
25 27
26 my $self = $class->SUPER::new (%arg, 28 my $self = $class->SUPER::new (%arg,
73 for values %{delete $ws->{w} || {}}; 75 for values %{delete $ws->{w} || {}};
74 } 76 }
75 77
76 delete $self->{items}; 78 delete $self->{items};
77 $::INV->clear; 79 $::INV->clear;
80 $::INVR->clear;
78 $::INVR_HB->clear; 81 $::INVR_HB->clear;
79 $::FLOORBOX->clear; 82 $::FLOORBOX->clear;
80 }); 83 });
81 84
82 $self->{map_widget}->add_command (@$_) 85 $self->{map_widget}->add_command (@$_)
89 92
90 { 93 {
91 $self->{noface} = my $tex = $TEX_NOFACE; 94 $self->{noface} = my $tex = $TEX_NOFACE;
92 $self->{map}->set_texture (2, @$tex{qw(name w h s t)}, @{$tex->{minified}}); 95 $self->{map}->set_texture (2, @$tex{qw(name w h s t)}, @{$tex->{minified}});
93 } 96 }
97
98# $self->{expire_count} = DC::DB::FIRST_TILE_ID; # minimum non-fixed tile id
99# $self->{expire_w} = EV::timer 1, 1, sub {
100# my $count = (int @{ $self->{texture} } / MIN_TEXTURE_UNUSED) || 1;
101#
102# for ($self->{map}->expire_textures ($self->{expire_count}, $count)) {
103# warn DC::SvREFCNT $self->{texture}[$_];
104# $self->{texture}[$_]->unload;
105# warn "expire texture $_\n";#d#
106# }
107#
108# ($self->{expire_count} += $count) < @{ $self->{texture} }
109# or $self->{expire_count} = DC::DB::FIRST_TILE_ID;
110# warn "count is $count\n";#d#
111# };
94 112
95 $self->{open_container} = 0; 113 $self->{open_container} = 0;
96 114
97 # per server 115 # per server
98 $self->{mapcache} = "mapcache_$self->{host}_$self->{port}"; 116 $self->{mapcache} = "mapcache_$self->{host}_$self->{port}";
545 7, 0, (new DC::UI::Label text => "Skill", expand => 1, align => 0), 563 7, 0, (new DC::UI::Label text => "Skill", expand => 1, align => 0),
546 ]; 564 ];
547 565
548 my @add = @$sw; 566 my @add = @$sw;
549 567
550 my $TOOLTIP_ALL = "\n\n<small>Left click - ready skill\nMiddle click - use spell\nRight click - further options</small>"; 568 my $TOOLTIP_ALL = "\n\n<small>Left click - ready skill\nMiddle click - use skill\nRight click - further options</small>";
551 569
552 my @TOOLTIP_LVL = (tooltip => "<b>Level</b>. The level of the skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1); 570 my @TOOLTIP_LVL = (tooltip => "<b>Level</b>. The level of the skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1);
553 my @TOOLTIP_EXP = (tooltip => "<b>Experience</b>. The experience points you have in this skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1); 571 my @TOOLTIP_EXP = (tooltip => "<b>Experience</b>. The experience points you have in this skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1);
554 572
555 my ($x, $y) = (0, 1); 573 my ($x, $y) = (0, 1);
655 for my $tile (@$missing) { 673 for my $tile (@$missing) {
656 next if $self->{delay}{$tile}; 674 next if $self->{delay}{$tile};
657 675
658 $delay = 1; 676 $delay = 1;
659 677
660 if (my $tex = $::CONN->{texture}[$tile]) { 678 if (my $tex = $self->{texture}[$tile]) {
661 $tex->upload; 679 $tex->upload;
662 } else { 680 } else {
663 $self->{delay}{$tile} = 1; 681 $self->{delay}{$tile} = 1;
664 682
665 # we assume the face is in-flight and will eventually come 683 # we assume the face is in-flight and will eventually arrive
666 push @{$self->{tile_cb}{$tile}}, sub { 684 push @{$self->{tile_cb}{$tile}}, sub {
667 delete $self->{delay}{$tile}; 685 delete $self->{delay}{$tile};
668 $_[0]->upload; 686 $_[0]->upload;
669 }; 687 };
670 } 688 }
671 } 689 }
672 690
673 if ($delay) { 691 if ($delay) {
674 # delay the map drawing a tiny bit in the hope of getting the missing fetched 692 # delay the map drawing a tiny bit in the hope of getting the missing tiles fetched
675 EV::once undef, 0, 0.03, sub { 693 EV::once undef, 0, 0.03, sub {
676 $self->{map_widget}->update 694 $self->{map_widget}->update
677 if $self->{map_widget}; 695 if $self->{map_widget};
678 }; 696 };
679 } else { 697 } else {
1096 1114
1097 ## try to create single paragraphs of multiple lines sent by the server 1115 ## try to create single paragraphs of multiple lines sent by the server
1098 # no longer neecssary with TRT servers 1116 # no longer neecssary with TRT servers
1099 #$text =~ s/(?<=\S)\n(?=\w)/ /g; 1117 #$text =~ s/(?<=\S)\n(?=\w)/ /g;
1100 1118
1101 for (split /\n/, $text) {
1102 ::message ({ 1119 ::message ({
1103 fg => $fg, 1120 fg => $fg,
1104 markup => $_, 1121 markup => $text,
1105 type => $type, 1122 type => $type,
1106 extra => [@extra], 1123 extra => [@extra],
1107 color_flags => $color, #d# ugly, kill 1124 color_flags => $color, #d# ugly, kill
1108 }); 1125 });
1109 1126
1110 $color &= ~NDI_CLEAR; # only clear once for multiline messages 1127# $color &= ~NDI_CLEAR; # only clear once for multiline messages
1111 # actually, this is an ugly design. _we_ should control the channels, 1128# # actually, this is an ugly design. _we_ should control the channels,
1112 # not some random other widget, as the channels are clearly protocol-specific. 1129# # not some random other widget, as the channels are clearly protocol-specific.
1113 # then we could also react to flags such as CLEAR without resorting to 1130# # then we could also react to flags such as CLEAR without resorting to
1114 # hacks such as color_flags, above. 1131# # hacks such as color_flags, above.
1115 }
1116 1132
1117 $self->{statusbox}->add ($text, 1133 $self->{statusbox}->add ($text,
1118 group => $text, 1134 group => $text,
1119 fg => $fg, 1135 fg => $fg,
1120 timeout => $color >= 2 ? 180 : 10, 1136 timeout => $color >= 2 ? 180 : 10,
1544} 1560}
1545 1561
1546sub send { 1562sub send {
1547 my ($self, $msg) = @_; 1563 my ($self, $msg) = @_;
1548 1564
1549 $self->{textview}->add_paragraph ({ markup => "\n" . DC::asxml $msg }); 1565 $self->{textview}->add_paragraph ({
1566 markup =>
1567 "\n<span foreground='#ffff00'><b>"
1568 . (DC::asxml $msg)
1569 . "</b></span>"
1570 });
1550 $self->{textview}->scroll_to_bottom; 1571 $self->{textview}->scroll_to_bottom;
1551 1572
1552 $self->{conn}->send_ext_msg (npc_dialog_tell => $self->{id}, $msg); 1573 $self->{conn}->send_ext_msg (npc_dialog_tell => $self->{id}, $msg);
1553} 1574}
1554 1575

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines