ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/MapWidget.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/MapWidget.pm (file contents):
Revision 1.87 by root, Sun Oct 8 21:57:54 2006 UTC vs.
Revision 1.91 by root, Tue Nov 7 22:41:27 2006 UTC

80 80
81sub editor_invoke { 81sub editor_invoke {
82 my $editsup = $::CONN && $::CONN->{editor_support} 82 my $editsup = $::CONN && $::CONN->{editor_support}
83 or return; 83 or return;
84 84
85 my ($pid, $fh); 85 CFPlus::background {
86 unless ($pid = open $fh, "-|:utf8", "-") {
87 $SIG{__DIE__} = sub {
88 my $msg = $_[0];
89 $msg =~ s/\n+/\n/;
90 warn "FATAL: $msg";
91 CFPlus::_exit 99;
92 };
93
94 open STDERR, ">&STDOUT";
95 binmode STDOUT, ":utf8";
96 binmode STDERR, ":utf8";
97 close $fh;
98
99 $| = 1;
100 print "preparing editor startup...\n"; 86 print "preparing editor startup...\n";
101 CFPlus::set_proxy; 87 CFPlus::set_proxy;
102 88
103 my $server = $editsup->{gameserver} || "default"; 89 my $server = $editsup->{gameserver} || "default";
104 $server =~ s/([^a-zA-Z0-9_\-])/sprintf "=%x=", ord $1/ge; 90 $server =~ s/([^a-zA-Z0-9_\-])/sprintf "=%x=", ord $1/ge;
197# } 183# }
198 } else { 184 } else {
199 die "viewvc parse error, unable to detect revision\n"; 185 die "viewvc parse error, unable to detect revision\n";
200 } 186 }
201 } 187 }
202
203 CFPlus::_exit;
204 }
205
206 my $buffer;
207
208 Event->io (fd => $fh, poll => 'r', cb => sub {
209 unless (sysread $fh, $buffer, 4096, length $buffer) {
210 $_[0]->w->cancel;
211 $buffer .= "done\n";
212 }
213
214 while ($buffer =~ s/^(.*)\n//) {
215 ::message ({
216 markup => "editor($pid): " . CFPlus::asxml $1,
217 });
218 }
219 }); 188 }
220} 189}
221 190
222sub invoke_button_down { 191sub invoke_button_down {
223 my ($self, $ev, $x, $y) = @_; 192 my ($self, $ev, $x, $y) = @_;
224 193
225 if ($ev->{button} == 1) { 194 if ($ev->{button} == 1) {
226 $self->grab_focus; 195 $self->grab_focus;
227 return unless $::CONN; 196 return unless $::CONN;
228 197
229 my $x = 1 + CFPlus::floor +($ev->{x} - $self->{sx0}) / $self->{tilesize} - $self->{sx}; 198 my $x = $self->{dx} + CFPlus::floor +($ev->{x} - $self->{sx0}) / $self->{tilesize};
230 my $y = 1 + CFPlus::floor +($ev->{y} - $self->{sy0}) / $self->{tilesize} - $self->{sy}; 199 my $y = $self->{dy} + CFPlus::floor +($ev->{y} - $self->{sy0}) / $self->{tilesize};
231 200
232 $x -= int 0.5 * $self->{sw}; 201 $x -= CFPlus::floor $::MAP->w * 0.5;
233 $y -= int 0.5 * $self->{sh}; 202 $y -= CFPlus::floor $::MAP->h * 0.5;
234 203
235 $::CONN->lookat ($x, $y) 204 $::CONN->lookat ($x, $y)
236 if $::CONN; 205 if $::CONN;
237 206
238 } elsif ($ev->{button} == 2) { 207 } elsif ($ev->{button} == 2) {
499 unless $focused || !$::FAST; 468 unless $focused || !$::FAST;
500 469
501 if (delete $self->{need_update}) { 470 if (delete $self->{need_update}) {
502 my $tilesize = $self->{tilesize} = int 32 * $::CFG->{map_scale}; 471 my $tilesize = $self->{tilesize} = int 32 * $::CFG->{map_scale};
503 472
473 my $sw = $self->{sw} = 1 + CFPlus::ceil $self->{w} / $tilesize;
474 my $sh = $self->{sh} = 1 + CFPlus::ceil $self->{h} / $tilesize;
475
504 my $sx = $self->{sx} = CFPlus::ceil $::CFG->{map_shift_x} / $tilesize; 476 my $sx = CFPlus::ceil $::CFG->{map_shift_x} / $tilesize;
505 my $sy = $self->{sy} = CFPlus::ceil $::CFG->{map_shift_y} / $tilesize; 477 my $sy = CFPlus::ceil $::CFG->{map_shift_y} / $tilesize;
506 478
507 my $sx0 = $self->{sx0} = $::CFG->{map_shift_x} - $sx * $tilesize; 479 my $sx0 = $self->{sx0} = $::CFG->{map_shift_x} - $sx * $tilesize;
508 my $sy0 = $self->{sy0} = $::CFG->{map_shift_y} - $sy * $tilesize; 480 my $sy0 = $self->{sy0} = $::CFG->{map_shift_y} - $sy * $tilesize;
509 481
510 my $sw = $self->{sw} = 1 + CFPlus::ceil $self->{w} / $tilesize; 482 my $dx = $self->{dx} = CFPlus::ceil 0.5 * ($::MAP->w - $sw) - $sx;
511 my $sh = $self->{sh} = 1 + CFPlus::ceil $self->{h} / $tilesize; 483 my $dy = $self->{dy} = CFPlus::ceil 0.5 * ($::MAP->h - $sh) - $sy;
512 484
513 if ($::CFG->{fow_enable}) { 485 if ($::CFG->{fow_enable}) {
514 my ($w, $h, $data) = $::MAP->fow_texture ($sx, $sy, 0, 0, $sw, $sh); 486 my ($w, $h, $data) = $::MAP->fow_texture ($dx, $dy, $sw, $sh);
515 487
516 if ($::CFG->{fow_smooth} && $CFPlus::OpenGL::GL_VERSION >= 1.2) { # smooth fog of war 488 if ($::CFG->{fow_smooth} && $CFPlus::OpenGL::GL_VERSION >= 1.2) { # smooth fog of war
517 glConvolutionParameter (GL_CONVOLUTION_2D, GL_CONVOLUTION_BORDER_MODE, GL_CONSTANT_BORDER); 489 glConvolutionParameter (GL_CONVOLUTION_2D, GL_CONVOLUTION_BORDER_MODE, GL_CONSTANT_BORDER);
518 glConvolutionFilter2D ( 490 glConvolutionFilter2D (
519 GL_CONVOLUTION_2D, 491 GL_CONVOLUTION_2D,
541 513
542 glPushMatrix; 514 glPushMatrix;
543 glTranslate $sx0, $sy0; 515 glTranslate $sx0, $sy0;
544 glScale $::CFG->{map_scale}, $::CFG->{map_scale}; 516 glScale $::CFG->{map_scale}, $::CFG->{map_scale};
545 517
546 $::MAP->draw ($sx, $sy, 0, 0, $sw, $sh); 518 $::MAP->draw ($dx, $dy, $sw, $sh);
547 519
548 glScale 32, 32; 520 glScale 32, 32;
549 521
550 if (my $tex = $self->{fow_texture}) { 522 if (my $tex = $self->{fow_texture}) {
551 glEnable GL_TEXTURE_2D; 523 glEnable GL_TEXTURE_2D;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines