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.3 by root, Sun Feb 5 05:08:00 2006 UTC vs.
Revision 1.4 by root, Sun Feb 5 05:32:57 2006 UTC

11=head2 METHODS 11=head2 METHODS
12 12
13=over 4 13=over 4
14 14
15=cut 15=cut
16
17package GCE::Map::DrawingArea;
18
19use Glib::Object::Subclass Gtk2::DrawingArea,
20 signals => { size_allocate => \&GCE::Map::do_size_allocate_rounded };
21 16
22package GCE::Map; 17package GCE::Map;
23 18
24use strict; 19use strict;
25 20
27 22
28use Crossfire; 23use Crossfire;
29use Crossfire::Gtk2; 24use Crossfire::Gtk2;
30 25
31use Glib::Object::Subclass 26use Glib::Object::Subclass
32 'GCE::Map::DrawingArea'; 27 'Gtk2::DrawingArea';
33 28
34use List::Util qw(min max); 29use List::Util qw(min max);
35 30
36sub INIT_INSTANCE { 31sub INIT_INSTANCE {
37 my ($self) = @_; 32 my ($self) = @_;
39 $self->signal_connect (destroy => sub { %{$_[0]} = () }); 34 $self->signal_connect (destroy => sub { %{$_[0]} = () });
40 $self->signal_connect (realize => sub { 35 $self->signal_connect (realize => sub {
41 my ($self) = @_; 36 my ($self) = @_;
42 37
43 $self->{window} = $self->window; 38 $self->{window} = $self->window;
44
45 my $window = $self->get_toplevel
46 or return;
47
48 my $hints = new Gtk2::Gdk::Geometry;
49 $hints->base_width (TILESIZE); $hints->base_height (TILESIZE);
50 $hints->width_inc (TILESIZE); $hints->height_inc (TILESIZE);
51
52 $window->set_geometry_hints ($self, $hints, [qw(base-size resize-inc)]);
53 39
54 1 40 1
55 }); 41 });
56 42
57 #$self->set_redraw_on_allocate (0); # nope 43 #$self->set_redraw_on_allocate (0); # nope
274 no integer; 260 no integer;
275 261
276 my $ox = $self->{x}; my $ix = int $ox / TILESIZE; 262 my $ox = $self->{x}; my $ix = int $ox / TILESIZE;
277 my $oy = $self->{y}; my $iy = int $oy / TILESIZE; 263 my $oy = $self->{y}; my $iy = int $oy / TILESIZE;
278 264
279# for my $area ($event->region->get_rectangles) { 265 # get_rectangles is buggy in older versions
280 for my $area ($event->area) { 266 for my $area ($Gtk2::VERSION >= 1.115 ? $event->region->get_rectangles : $event->area) {
281 my ($x, $y, $w, $h) = $area->values; # x y w h 267 my ($x, $y, $w, $h) = $area->values; # x y w h
282 268
283 my @x = ((int ($ox + $x) / TILESIZE) .. int +($ox + $x + $w + TILESIZE - 1) / TILESIZE); 269 my @x = ((int ($ox + $x) / TILESIZE) .. int +($ox + $x + $w + TILESIZE - 1) / TILESIZE);
284 my @y = ((int ($oy + $y) / TILESIZE) .. int +($oy + $y + $h + TILESIZE - 1) / TILESIZE); 270 my @y = ((int ($oy + $y) / TILESIZE) .. int +($oy + $y + $h + TILESIZE - 1) / TILESIZE);
285 271

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines