ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/gde/GCE/Map.pm
(Generate patch)

Comparing deliantra/gde/GCE/Map.pm (file contents):
Revision 1.1 by root, Sun Feb 5 04:30:17 2006 UTC vs.
Revision 1.2 by root, Sun Feb 5 04:53:50 2006 UTC

53 53
54 1 54 1
55 }); 55 });
56 56
57 #$self->set_redraw_on_allocate (0); # nope 57 #$self->set_redraw_on_allocate (0); # nope
58 $self->double_buffered (1); 58 $self->double_buffered (0);
59 59
60 $self->signal_connect (size_request => sub { 60 $self->signal_connect (size_request => sub {
61 $_[1]->width (20 * TILESIZE); 61 $_[1]->width (20 * TILESIZE);
62 $_[1]->height (20 * TILESIZE); 62 $_[1]->height (20 * TILESIZE);
63 63
74 my ($x, $y) = ($event->x, $event->y); 74 my ($x, $y) = ($event->x, $event->y);
75 75
76 if ($_[1]->button == 2) { 76 if ($_[1]->button == 2) {
77 $_[0]->grab_focus; 77 $_[0]->grab_focus;
78 $self->{in_drag} = [$self->{x}, $self->{y}, $x, $y]; 78 $self->{in_drag} = [$self->{x}, $self->{y}, $x, $y];
79 return 0;
79 } 80 }
80 81
81 1 82 1
82 }); 83 });
83 84
94 my $ny = max 0, $di->[1] - $dy; 95 my $ny = max 0, $di->[1] - $dy;
95 96
96 $self->window->scroll ($self->{x} - $nx, $self->{y} - $ny); 97 $self->window->scroll ($self->{x} - $nx, $self->{y} - $ny);
97 98
98 ($self->{x}, $self->{y}) = ($nx, $ny); 99 ($self->{x}, $self->{y}) = ($nx, $ny);
100 return 0;
99 } 101 }
100 102
101 1; 103 1;
102 }); 104 });
103 105
104 $self->signal_connect (button_release_event => sub { 106 $self->signal_connect (button_release_event => sub {
105 my ($self) = @_; 107 my ($self) = @_;
106 108
107# if ($self->{in_drag}) {
108# }
109 delete $self->{in_drag}; 109 delete $self->{in_drag};
110 110
111 1 111 1
112 }); 112 });
113 113
274 no integer; 274 no integer;
275 275
276 my $ox = $self->{x}; my $ix = int $ox / TILESIZE; 276 my $ox = $self->{x}; my $ix = int $ox / TILESIZE;
277 my $oy = $self->{y}; my $iy = int $oy / TILESIZE; 277 my $oy = $self->{y}; my $iy = int $oy / TILESIZE;
278 278
279 for my $area ($event->region->get_rectangles) { 279# for my $area ($event->region->get_rectangles) {
280 for my $area ($event->area) {
280 my ($x, $y, $w, $h) = $area->values; # x y w h 281 my ($x, $y, $w, $h) = $area->values; # x y w h
281 282
282 my @x = ((int ($ox + $x) / TILESIZE) .. int +($ox + $x + $w + TILESIZE - 1) / TILESIZE); 283 my @x = ((int ($ox + $x) / TILESIZE) .. int +($ox + $x + $w + TILESIZE - 1) / TILESIZE);
283 my @y = ((int ($oy + $y) / TILESIZE) .. int +($oy + $y + $h + TILESIZE - 1) / TILESIZE); 284 my @y = ((int ($oy + $y) / TILESIZE) .. int +($oy + $y + $h + TILESIZE - 1) / TILESIZE);
284 285
289 290
290 my $pb = new Gtk2::Gdk::Pixbuf 'rgb', 0, 8, TILESIZE * (@x + 1), TILESIZE * (@y + 1); 291 my $pb = new Gtk2::Gdk::Pixbuf 'rgb', 0, 8, TILESIZE * (@x + 1), TILESIZE * (@y + 1);
291 $pb->fill (0x00000000); 292 $pb->fill (0x00000000);
292 293
293 for my $x (@x) { 294 for my $x (@x) {
295 my $as = $self->{map}{map}[$x];
294 for my $y (@y) { 296 for my $y (@y) {
295 for my $a (@{ $self->{map}{map}[$x][$y] || [] }) { 297 for my $a (@{ $as->[$y] || [] }) {
296 my $o = $ARCH->{$a->{_name}} 298 my $o = $ARCH->{$a->{_name}}
297 or (warn "arch '$a->{_name}' not found at ($x|$y)\n"), next; 299 or (warn "arch '$a->{_name}' not found at ($x|$y)\n"), next;
298 300
299 my $face = $a->{face} || $o->{face}; 301 my $face = $a->{face} || $o->{face};
300 my $tile = $TC->{$face} 302 my $tile = $TC->{$face}
327 329
328my $win = new Gtk2::Window 'toplevel'; 330my $win = new Gtk2::Window 'toplevel';
329my $map = new GCE::Map; 331my $map = new GCE::Map;
330$win->add ($map); 332$win->add ($map);
331$win->show_all; 333$win->show_all;
332$map->{map} = arch2map read_arch "$Crossfire::LIB/maps/dungeons/xyzzy-mines"; 334$map->{map} = arch2map read_arch "$Crossfire::LIB/maps/mlab/university1";
333main Gtk2; 335main Gtk2;
334 336
335=back 337=back
336 338
337=head1 AUTHOR 339=head1 AUTHOR

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines