… | |
… | |
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 | our $TEX_HIDDEN = new_from_resource DC::Texture |
|
|
24 | "hidden.png", minify => 1, mipmap => 1; |
|
|
25 | |
|
|
26 | sub MIN_TEXTURE_UNUSED() { 1 }#d# |
16 | |
27 | |
17 | sub new { |
28 | sub 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}"; |
… | |
… | |
255 | my %wkw = ( |
285 | my %wkw = ( |
256 | root => $DC::UI::ROOT, |
286 | root => $DC::UI::ROOT, |
257 | tooltip => $DC::UI::TOOLTIP, |
287 | tooltip => $DC::UI::TOOLTIP, |
258 | |
288 | |
259 | mapwidget => $::MAPWIDGET, |
289 | mapwidget => $::MAPWIDGET, |
|
|
290 | menubar => $::MENUBAR, |
|
|
291 | menupopup => $::MENUPOPUP, |
260 | buttonbar => $::BUTTONBAR, |
292 | buttonbar => $::BUTTONBAR, |
261 | metaserver => $::METASERVER, |
293 | metaserver => $::METASERVER, |
262 | buttonbar => $::BUTTONBAR, |
294 | buttonbar => $::BUTTONBAR, |
263 | login_button => $::LOGIN_BUTTON, |
295 | login_button => $::LOGIN_BUTTON, |
264 | quit_dialog => $::QUIT_DIALOG, |
296 | quit_dialog => $::QUIT_DIALOG, |
… | |
… | |
281 | |
313 | |
282 | floorbox => $::FLOORBOX, |
314 | floorbox => $::FLOORBOX, |
283 | help_window => $::HELP_WINDOW, |
315 | help_window => $::HELP_WINDOW, |
284 | message_window => $::MESSAGE_WINDOW, |
316 | message_window => $::MESSAGE_WINDOW, |
285 | message_dist => $::MESSAGE_DIST, |
317 | message_dist => $::MESSAGE_DIST, |
286 | statusbox => $::SDTATUSBOX, |
318 | statusbox => $::STATUSBOX, |
287 | |
319 | |
288 | inv => $::INV, |
320 | inv => $::INV, |
289 | invr => $::INVR, |
321 | invr => $::INVR, |
290 | invr_hb => $::INVR_HB, |
322 | invr_hb => $::INVR_HB, |
291 | ); |
323 | ); |
… | |
… | |
541 | 7, 0, (new DC::UI::Label text => "Skill", expand => 1, align => 0), |
573 | 7, 0, (new DC::UI::Label text => "Skill", expand => 1, align => 0), |
542 | ]; |
574 | ]; |
543 | |
575 | |
544 | my @add = @$sw; |
576 | my @add = @$sw; |
545 | |
577 | |
546 | my $TOOLTIP_ALL = "\n\n<small>Left click - ready skill\nMiddle click - use spell\nRight click - further options</small>"; |
578 | my $TOOLTIP_ALL = "\n\n<small>Left click - ready skill\nMiddle click - use skill\nRight click - further options</small>"; |
547 | |
579 | |
548 | my @TOOLTIP_LVL = (tooltip => "<b>Level</b>. The level of the skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1); |
580 | 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); |
581 | my @TOOLTIP_EXP = (tooltip => "<b>Experience</b>. The experience points you have in this skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1); |
550 | |
582 | |
551 | my ($x, $y) = (0, 1); |
583 | my ($x, $y) = (0, 1); |
… | |
… | |
637 | } |
669 | } |
638 | |
670 | |
639 | sub map_scroll { |
671 | sub map_scroll { |
640 | my ($self, $dx, $dy) = @_; |
672 | my ($self, $dx, $dy) = @_; |
641 | |
673 | |
642 | $self->{map}->scroll ($dx, $dy); |
674 | $self->{map_widget}->scroll ($dx, $dy); |
643 | } |
675 | } |
644 | |
676 | |
645 | sub feed_map1a { |
677 | sub feed_map1a { |
646 | my ($self, $data) = @_; |
678 | my ($self, $data) = @_; |
647 | |
679 | |
… | |
… | |
651 | for my $tile (@$missing) { |
683 | for my $tile (@$missing) { |
652 | next if $self->{delay}{$tile}; |
684 | next if $self->{delay}{$tile}; |
653 | |
685 | |
654 | $delay = 1; |
686 | $delay = 1; |
655 | |
687 | |
656 | if (my $tex = $::CONN->{texture}[$tile]) { |
688 | if (my $tex = $self->{texture}[$tile]) { |
657 | $tex->upload; |
689 | $tex->upload; |
658 | } else { |
690 | } else { |
659 | $self->{delay}{$tile} = 1; |
691 | $self->{delay}{$tile} = 1; |
660 | |
692 | |
661 | # we assume the face is in-flight and will eventually come |
693 | # we assume the face is in-flight and will eventually arrive |
662 | push @{$self->{tile_cb}{$tile}}, sub { |
694 | push @{$self->{tile_cb}{$tile}}, sub { |
663 | delete $self->{delay}{$tile}; |
695 | delete $self->{delay}{$tile}; |
664 | $_[0]->upload; |
696 | $_[0]->upload; |
665 | }; |
697 | }; |
666 | } |
698 | } |
667 | } |
699 | } |
668 | |
700 | |
669 | if ($delay) { |
701 | if ($delay) { |
670 | # delay the map drawing a tiny bit in the hope of getting the missing fetched |
702 | # delay the map drawing a tiny bit in the hope of getting the missing tiles fetched |
671 | EV::once undef, 0, 0.03, sub { |
703 | EV::once undef, 0, 0.03, sub { |
672 | $self->{map_widget}->update |
704 | $self->{map_widget}->update |
673 | if $self->{map_widget}; |
705 | if $self->{map_widget}; |
674 | }; |
706 | }; |
675 | } else { |
707 | } else { |
… | |
… | |
1092 | |
1124 | |
1093 | ## try to create single paragraphs of multiple lines sent by the server |
1125 | ## try to create single paragraphs of multiple lines sent by the server |
1094 | # no longer neecssary with TRT servers |
1126 | # no longer neecssary with TRT servers |
1095 | #$text =~ s/(?<=\S)\n(?=\w)/ /g; |
1127 | #$text =~ s/(?<=\S)\n(?=\w)/ /g; |
1096 | |
1128 | |
1097 | for (split /\n/, $text) { |
|
|
1098 | ::message ({ |
1129 | ::message ({ |
1099 | fg => $fg, |
1130 | fg => $fg, |
1100 | markup => $_, |
1131 | markup => $text, |
1101 | type => $type, |
1132 | type => $type, |
1102 | extra => [@extra], |
1133 | extra => [@extra], |
1103 | color_flags => $color, #d# ugly, kill |
1134 | color_flags => $color, #d# ugly, kill |
1104 | }); |
1135 | }); |
1105 | |
1136 | |
1106 | $color &= ~NDI_CLEAR; # only clear once for multiline messages |
1137 | # $color &= ~NDI_CLEAR; # only clear once for multiline messages |
1107 | # actually, this is an ugly design. _we_ should control the channels, |
1138 | # # actually, this is an ugly design. _we_ should control the channels, |
1108 | # not some random other widget, as the channels are clearly protocol-specific. |
1139 | # # 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 |
1140 | # # then we could also react to flags such as CLEAR without resorting to |
1110 | # hacks such as color_flags, above. |
1141 | # # hacks such as color_flags, above. |
1111 | } |
|
|
1112 | |
1142 | |
1113 | $self->{statusbox}->add ($text, |
1143 | $self->{statusbox}->add ($text, |
1114 | group => $text, |
1144 | group => $text, |
1115 | fg => $fg, |
1145 | fg => $fg, |
1116 | timeout => $color >= 2 ? 180 : 10, |
1146 | timeout => $color >= 2 ? 180 : 10, |
… | |
… | |
1364 | |
1394 | |
1365 | $self->update_server_info; |
1395 | $self->update_server_info; |
1366 | |
1396 | |
1367 | $self->send_command ("output-rate $::CFG->{output_rate}") if $::CFG->{output_rate} > 0; |
1397 | $self->send_command ("output-rate $::CFG->{output_rate}") if $::CFG->{output_rate} > 0; |
1368 | $self->send_command ("pickup $::CFG->{pickup}"); |
1398 | $self->send_command ("pickup $::CFG->{pickup}"); |
|
|
1399 | |
|
|
1400 | $self->send_exti_msg (clientlog => sprintf "OpenGL Info: %s [%s]", |
|
|
1401 | DC::OpenGL::gl_vendor, DC::OpenGL::gl_version);#d# |
1369 | } |
1402 | } |
1370 | |
1403 | |
1371 | sub lookat { |
1404 | sub lookat { |
1372 | my ($self, $x, $y) = @_; |
1405 | my ($self, $x, $y) = @_; |
1373 | |
1406 | |
… | |
… | |
1537 | } |
1570 | } |
1538 | |
1571 | |
1539 | sub send { |
1572 | sub send { |
1540 | my ($self, $msg) = @_; |
1573 | my ($self, $msg) = @_; |
1541 | |
1574 | |
1542 | $self->{textview}->add_paragraph ({ markup => "\n" . DC::asxml $msg }); |
1575 | $self->{textview}->add_paragraph ({ |
|
|
1576 | markup => |
|
|
1577 | "\n<span foreground='#ffff00'><b>" |
|
|
1578 | . (DC::asxml $msg) |
|
|
1579 | . "</b></span>" |
|
|
1580 | }); |
1543 | $self->{textview}->scroll_to_bottom; |
1581 | $self->{textview}->scroll_to_bottom; |
1544 | |
1582 | |
1545 | $self->{conn}->send_ext_msg (npc_dialog_tell => $self->{id}, $msg); |
1583 | $self->{conn}->send_ext_msg (npc_dialog_tell => $self->{id}, $msg); |
1546 | } |
1584 | } |
1547 | |
1585 | |