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.199 by root, Sat Jul 19 20:33:47 2008 UTC vs.
Revision 1.207 by root, Sat Dec 20 19:45:50 2008 UTC

11use DC::Pod; 11use DC::Pod;
12use DC::Macro; 12use DC::Macro;
13use DC::Item; 13use DC::Item;
14 14
15use base 'Deliantra::Protocol::Base'; 15use base 'Deliantra::Protocol::Base';
16
17our $TEX_DIALOGUE = new_from_resource DC::Texture
18 "dialogue.png", minify => 1, mipmap => 1;
19
20our $TEX_NOFACE = new_from_resource DC::Texture
21 "noface.png", minify => 1, mipmap => 1;
22
23our $TEX_HIDDEN = new_from_resource DC::Texture
24 "hidden.png", minify => 1, mipmap => 1;
25
26sub MIN_TEXTURE_UNUSED() { 1 }#d#
16 27
17sub new { 28sub new {
18 my ($class, %arg) = @_; 29 my ($class, %arg) = @_;
19 30
20 my $self = $class->SUPER::new (%arg, 31 my $self = $class->SUPER::new (%arg,
67 for values %{delete $ws->{w} || {}}; 78 for values %{delete $ws->{w} || {}};
68 } 79 }
69 80
70 delete $self->{items}; 81 delete $self->{items};
71 $::INV->clear; 82 $::INV->clear;
83 $::INVR->clear;
72 $::INVR_HB->clear; 84 $::INVR_HB->clear;
73 $::FLOORBOX->clear; 85 $::FLOORBOX->clear;
74 }); 86 });
75 87
76 $self->{map_widget}->add_command (@$_) 88 $self->{map_widget}->add_command (@$_)
77 for @cmd_help; 89 for @cmd_help;
78 90
79 { 91 {
80 $self->{dialogue} = my $tex = new_from_file DC::Texture 92 $self->{dialogue} = my $tex = $TEX_DIALOGUE;
81 DC::find_rcfile "dialogue.png", minify => 1, mipmap => 1;
82 $self->{map}->set_texture (1, @$tex{qw(name w h s t)}, @{$tex->{minified}}); 93 $self->{map}->set_texture (1, @$tex{qw(name w h s t)}, @{$tex->{minified}});
83 } 94 }
84 95
85 { 96 {
86 $self->{noface} = my $tex = new_from_file DC::Texture 97 $self->{noface} = my $tex = $TEX_NOFACE;
87 DC::find_rcfile "noface.png", minify => 1, mipmap => 1;
88 $self->{map}->set_texture (2, @$tex{qw(name w h s t)}, @{$tex->{minified}}); 98 $self->{map}->set_texture (2, @$tex{qw(name w h s t)}, @{$tex->{minified}});
89 } 99 }
100
101 {
102 $self->{hidden} = my $tex = $TEX_HIDDEN;
103 $self->{map}->set_texture (3, @$tex{qw(name w h s t)}, @{$tex->{minified}});
104 }
105
106# $self->{expire_count} = DC::DB::FIRST_TILE_ID; # minimum non-fixed tile id
107# $self->{expire_w} = EV::timer 1, 1, sub {
108# my $count = (int @{ $self->{texture} } / MIN_TEXTURE_UNUSED) || 1;
109#
110# for ($self->{map}->expire_textures ($self->{expire_count}, $count)) {
111# warn DC::SvREFCNT $self->{texture}[$_];
112# $self->{texture}[$_]->unload;
113# warn "expire texture $_\n";#d#
114# }
115#
116# ($self->{expire_count} += $count) < @{ $self->{texture} }
117# or $self->{expire_count} = DC::DB::FIRST_TILE_ID;
118# warn "count is $count\n";#d#
119# };
90 120
91 $self->{open_container} = 0; 121 $self->{open_container} = 0;
92 122
93 # per server 123 # per server
94 $self->{mapcache} = "mapcache_$self->{host}_$self->{port}"; 124 $self->{mapcache} = "mapcache_$self->{host}_$self->{port}";
541 7, 0, (new DC::UI::Label text => "Skill", expand => 1, align => 0), 571 7, 0, (new DC::UI::Label text => "Skill", expand => 1, align => 0),
542 ]; 572 ];
543 573
544 my @add = @$sw; 574 my @add = @$sw;
545 575
546 my $TOOLTIP_ALL = "\n\n<small>Left click - ready skill\nMiddle click - use spell\nRight click - further options</small>"; 576 my $TOOLTIP_ALL = "\n\n<small>Left click - ready skill\nMiddle click - use skill\nRight click - further options</small>";
547 577
548 my @TOOLTIP_LVL = (tooltip => "<b>Level</b>. The level of the skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1); 578 my @TOOLTIP_LVL = (tooltip => "<b>Level</b>. The level of the skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1);
549 my @TOOLTIP_EXP = (tooltip => "<b>Experience</b>. The experience points you have in this skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1); 579 my @TOOLTIP_EXP = (tooltip => "<b>Experience</b>. The experience points you have in this skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1);
550 580
551 my ($x, $y) = (0, 1); 581 my ($x, $y) = (0, 1);
651 for my $tile (@$missing) { 681 for my $tile (@$missing) {
652 next if $self->{delay}{$tile}; 682 next if $self->{delay}{$tile};
653 683
654 $delay = 1; 684 $delay = 1;
655 685
656 if (my $tex = $::CONN->{texture}[$tile]) { 686 if (my $tex = $self->{texture}[$tile]) {
657 $tex->upload; 687 $tex->upload;
658 } else { 688 } else {
659 $self->{delay}{$tile} = 1; 689 $self->{delay}{$tile} = 1;
660 690
661 # we assume the face is in-flight and will eventually come 691 # we assume the face is in-flight and will eventually arrive
662 push @{$self->{tile_cb}{$tile}}, sub { 692 push @{$self->{tile_cb}{$tile}}, sub {
663 delete $self->{delay}{$tile}; 693 delete $self->{delay}{$tile};
664 $_[0]->upload; 694 $_[0]->upload;
665 }; 695 };
666 } 696 }
667 } 697 }
668 698
669 if ($delay) { 699 if ($delay) {
670 # delay the map drawing a tiny bit in the hope of getting the missing fetched 700 # delay the map drawing a tiny bit in the hope of getting the missing tiles fetched
671 EV::once undef, 0, 0.03, sub { 701 EV::once undef, 0, 0.03, sub {
672 $self->{map_widget}->update 702 $self->{map_widget}->update
673 if $self->{map_widget}; 703 if $self->{map_widget};
674 }; 704 };
675 } else { 705 } else {
1092 1122
1093 ## try to create single paragraphs of multiple lines sent by the server 1123 ## try to create single paragraphs of multiple lines sent by the server
1094 # no longer neecssary with TRT servers 1124 # no longer neecssary with TRT servers
1095 #$text =~ s/(?<=\S)\n(?=\w)/ /g; 1125 #$text =~ s/(?<=\S)\n(?=\w)/ /g;
1096 1126
1097 for (split /\n/, $text) {
1098 ::message ({ 1127 ::message ({
1099 fg => $fg, 1128 fg => $fg,
1100 markup => $_, 1129 markup => $text,
1101 type => $type, 1130 type => $type,
1102 extra => [@extra], 1131 extra => [@extra],
1103 color_flags => $color, #d# ugly, kill 1132 color_flags => $color, #d# ugly, kill
1104 }); 1133 });
1105 1134
1106 $color &= ~NDI_CLEAR; # only clear once for multiline messages 1135# $color &= ~NDI_CLEAR; # only clear once for multiline messages
1107 # actually, this is an ugly design. _we_ should control the channels, 1136# # actually, this is an ugly design. _we_ should control the channels,
1108 # not some random other widget, as the channels are clearly protocol-specific. 1137# # not some random other widget, as the channels are clearly protocol-specific.
1109 # then we could also react to flags such as CLEAR without resorting to 1138# # then we could also react to flags such as CLEAR without resorting to
1110 # hacks such as color_flags, above. 1139# # hacks such as color_flags, above.
1111 }
1112 1140
1113 $self->{statusbox}->add ($text, 1141 $self->{statusbox}->add ($text,
1114 group => $text, 1142 group => $text,
1115 fg => $fg, 1143 fg => $fg,
1116 timeout => $color >= 2 ? 180 : 10, 1144 timeout => $color >= 2 ? 180 : 10,
1364 1392
1365 $self->update_server_info; 1393 $self->update_server_info;
1366 1394
1367 $self->send_command ("output-rate $::CFG->{output_rate}") if $::CFG->{output_rate} > 0; 1395 $self->send_command ("output-rate $::CFG->{output_rate}") if $::CFG->{output_rate} > 0;
1368 $self->send_command ("pickup $::CFG->{pickup}"); 1396 $self->send_command ("pickup $::CFG->{pickup}");
1397
1398 $self->send_exti_msg (clientlog => sprintf "OpenGL Info: %s [%s]",
1399 DC::OpenGL::gl_vendor, DC::OpenGL::gl_version);#d#
1369} 1400}
1370 1401
1371sub lookat { 1402sub lookat {
1372 my ($self, $x, $y) = @_; 1403 my ($self, $x, $y) = @_;
1373 1404
1537} 1568}
1538 1569
1539sub send { 1570sub send {
1540 my ($self, $msg) = @_; 1571 my ($self, $msg) = @_;
1541 1572
1542 $self->{textview}->add_paragraph ({ markup => "\n" . DC::asxml $msg }); 1573 $self->{textview}->add_paragraph ({
1574 markup =>
1575 "\n<span foreground='#ffff00'><b>"
1576 . (DC::asxml $msg)
1577 . "</b></span>"
1578 });
1543 $self->{textview}->scroll_to_bottom; 1579 $self->{textview}->scroll_to_bottom;
1544 1580
1545 $self->{conn}->send_ext_msg (npc_dialog_tell => $self->{id}, $msg); 1581 $self->{conn}->send_ext_msg (npc_dialog_tell => $self->{id}, $msg);
1546} 1582}
1547 1583

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines