… | |
… | |
11 | use DC::Pod; |
11 | use DC::Pod; |
12 | use DC::Macro; |
12 | use DC::Macro; |
13 | use DC::Item; |
13 | use DC::Item; |
14 | |
14 | |
15 | use base 'Deliantra::Protocol::Base'; |
15 | use base 'Deliantra::Protocol::Base'; |
|
|
16 | |
|
|
17 | our $TEX_DIALOGUE = new_from_resource DC::Texture |
|
|
18 | "dialogue.png", minify => 1, mipmap => 1; |
|
|
19 | |
|
|
20 | our $TEX_NOFACE = new_from_resource DC::Texture |
|
|
21 | "noface.png", minify => 1, mipmap => 1; |
|
|
22 | |
|
|
23 | sub MIN_TEXTURE_UNUSED() { 1 }#d# |
16 | |
24 | |
17 | sub new { |
25 | sub new { |
18 | my ($class, %arg) = @_; |
26 | my ($class, %arg) = @_; |
19 | |
27 | |
20 | my $self = $class->SUPER::new (%arg, |
28 | my $self = $class->SUPER::new (%arg, |
… | |
… | |
67 | for values %{delete $ws->{w} || {}}; |
75 | for values %{delete $ws->{w} || {}}; |
68 | } |
76 | } |
69 | |
77 | |
70 | delete $self->{items}; |
78 | delete $self->{items}; |
71 | $::INV->clear; |
79 | $::INV->clear; |
|
|
80 | $::INVR->clear; |
72 | $::INVR_HB->clear; |
81 | $::INVR_HB->clear; |
73 | $::FLOORBOX->clear; |
82 | $::FLOORBOX->clear; |
74 | }); |
83 | }); |
75 | |
84 | |
76 | $self->{map_widget}->add_command (@$_) |
85 | $self->{map_widget}->add_command (@$_) |
77 | for @cmd_help; |
86 | for @cmd_help; |
78 | |
87 | |
79 | { |
88 | { |
80 | $self->{dialogue} = my $tex = new_from_file DC::Texture |
89 | $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}}); |
90 | $self->{map}->set_texture (1, @$tex{qw(name w h s t)}, @{$tex->{minified}}); |
83 | } |
91 | } |
84 | |
92 | |
85 | { |
93 | { |
86 | $self->{noface} = my $tex = new_from_file DC::Texture |
94 | $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}}); |
95 | $self->{map}->set_texture (2, @$tex{qw(name w h s t)}, @{$tex->{minified}}); |
89 | } |
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 | # }; |
90 | |
112 | |
91 | $self->{open_container} = 0; |
113 | $self->{open_container} = 0; |
92 | |
114 | |
93 | # per server |
115 | # per server |
94 | $self->{mapcache} = "mapcache_$self->{host}_$self->{port}"; |
116 | $self->{mapcache} = "mapcache_$self->{host}_$self->{port}"; |
… | |
… | |
541 | 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), |
542 | ]; |
564 | ]; |
543 | |
565 | |
544 | my @add = @$sw; |
566 | my @add = @$sw; |
545 | |
567 | |
546 | 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>"; |
547 | |
569 | |
548 | 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); |
549 | 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); |
550 | |
572 | |
551 | my ($x, $y) = (0, 1); |
573 | my ($x, $y) = (0, 1); |
… | |
… | |
637 | } |
659 | } |
638 | |
660 | |
639 | sub map_scroll { |
661 | sub map_scroll { |
640 | my ($self, $dx, $dy) = @_; |
662 | my ($self, $dx, $dy) = @_; |
641 | |
663 | |
642 | $self->{map}->scroll ($dx, $dy); |
664 | $self->{map_widget}->scroll ($dx, $dy); |
643 | } |
665 | } |
644 | |
666 | |
645 | sub feed_map1a { |
667 | sub feed_map1a { |
646 | my ($self, $data) = @_; |
668 | my ($self, $data) = @_; |
647 | |
669 | |
… | |
… | |
651 | for my $tile (@$missing) { |
673 | for my $tile (@$missing) { |
652 | next if $self->{delay}{$tile}; |
674 | next if $self->{delay}{$tile}; |
653 | |
675 | |
654 | $delay = 1; |
676 | $delay = 1; |
655 | |
677 | |
656 | if (my $tex = $::CONN->{texture}[$tile]) { |
678 | if (my $tex = $self->{texture}[$tile]) { |
657 | $tex->upload; |
679 | $tex->upload; |
658 | } else { |
680 | } else { |
659 | $self->{delay}{$tile} = 1; |
681 | $self->{delay}{$tile} = 1; |
660 | |
682 | |
661 | # we assume the face is in-flight and will eventually come |
683 | # we assume the face is in-flight and will eventually arrive |
662 | push @{$self->{tile_cb}{$tile}}, sub { |
684 | push @{$self->{tile_cb}{$tile}}, sub { |
663 | delete $self->{delay}{$tile}; |
685 | delete $self->{delay}{$tile}; |
664 | $_[0]->upload; |
686 | $_[0]->upload; |
665 | }; |
687 | }; |
666 | } |
688 | } |
667 | } |
689 | } |
668 | |
690 | |
669 | if ($delay) { |
691 | if ($delay) { |
670 | # 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 |
671 | EV::once undef, 0, 0.03, sub { |
693 | EV::once undef, 0, 0.03, sub { |
672 | $self->{map_widget}->update |
694 | $self->{map_widget}->update |
673 | if $self->{map_widget}; |
695 | if $self->{map_widget}; |
674 | }; |
696 | }; |
675 | } else { |
697 | } else { |
… | |
… | |
1092 | |
1114 | |
1093 | ## 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 |
1094 | # no longer neecssary with TRT servers |
1116 | # no longer neecssary with TRT servers |
1095 | #$text =~ s/(?<=\S)\n(?=\w)/ /g; |
1117 | #$text =~ s/(?<=\S)\n(?=\w)/ /g; |
1096 | |
1118 | |
1097 | for (split /\n/, $text) { |
|
|
1098 | ::message ({ |
1119 | ::message ({ |
1099 | fg => $fg, |
1120 | fg => $fg, |
1100 | markup => $_, |
1121 | markup => $text, |
1101 | type => $type, |
1122 | type => $type, |
1102 | extra => [@extra], |
1123 | extra => [@extra], |
1103 | color_flags => $color, #d# ugly, kill |
1124 | color_flags => $color, #d# ugly, kill |
1104 | }); |
1125 | }); |
1105 | |
1126 | |
1106 | $color &= ~NDI_CLEAR; # only clear once for multiline messages |
1127 | # $color &= ~NDI_CLEAR; # only clear once for multiline messages |
1107 | # actually, this is an ugly design. _we_ should control the channels, |
1128 | # # actually, this is an ugly design. _we_ should control the channels, |
1108 | # 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. |
1109 | # 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 |
1110 | # hacks such as color_flags, above. |
1131 | # # hacks such as color_flags, above. |
1111 | } |
|
|
1112 | |
1132 | |
1113 | $self->{statusbox}->add ($text, |
1133 | $self->{statusbox}->add ($text, |
1114 | group => $text, |
1134 | group => $text, |
1115 | fg => $fg, |
1135 | fg => $fg, |
1116 | timeout => $color >= 2 ? 180 : 10, |
1136 | timeout => $color >= 2 ? 180 : 10, |
… | |
… | |
1364 | |
1384 | |
1365 | $self->update_server_info; |
1385 | $self->update_server_info; |
1366 | |
1386 | |
1367 | $self->send_command ("output-rate $::CFG->{output_rate}") if $::CFG->{output_rate} > 0; |
1387 | $self->send_command ("output-rate $::CFG->{output_rate}") if $::CFG->{output_rate} > 0; |
1368 | $self->send_command ("pickup $::CFG->{pickup}"); |
1388 | $self->send_command ("pickup $::CFG->{pickup}"); |
|
|
1389 | |
|
|
1390 | $self->send_exti_msg (clientlog => sprintf "OpenGL Info: %s [%s]", |
|
|
1391 | DC::OpenGL::gl_vendor, DC::OpenGL::gl_version);#d# |
1369 | } |
1392 | } |
1370 | |
1393 | |
1371 | sub lookat { |
1394 | sub lookat { |
1372 | my ($self, $x, $y) = @_; |
1395 | my ($self, $x, $y) = @_; |
1373 | |
1396 | |
… | |
… | |
1537 | } |
1560 | } |
1538 | |
1561 | |
1539 | sub send { |
1562 | sub send { |
1540 | my ($self, $msg) = @_; |
1563 | my ($self, $msg) = @_; |
1541 | |
1564 | |
1542 | $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 | }); |
1543 | $self->{textview}->scroll_to_bottom; |
1571 | $self->{textview}->scroll_to_bottom; |
1544 | |
1572 | |
1545 | $self->{conn}->send_ext_msg (npc_dialog_tell => $self->{id}, $msg); |
1573 | $self->{conn}->send_ext_msg (npc_dialog_tell => $self->{id}, $msg); |
1546 | } |
1574 | } |
1547 | |
1575 | |