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

Comparing deliantra/gde/GCE/MapEditor.pm (file contents):
Revision 1.21 by elmex, Thu Mar 16 01:13:57 2006 UTC vs.
Revision 1.22 by elmex, Thu Mar 16 11:59:34 2006 UTC

13use Crossfire; 13use Crossfire;
14use Crossfire::Map; 14use Crossfire::Map;
15use Crossfire::MapWidget; 15use Crossfire::MapWidget;
16 16
17use GCE::AttrEdit; 17use GCE::AttrEdit;
18use GCE::Util;
18 19
19use Glib::Object::Subclass 20use Glib::Object::Subclass
20 Gtk2::Window; 21 Gtk2::Window;
21 22
22use strict; 23use strict;
103 if ($ea->special_arrow) { 104 if ($ea->special_arrow) {
104 $self->{map}->{window}->set_cursor (Gtk2::Gdk::Cursor->new ($ea->special_arrow)); 105 $self->{map}->{window}->set_cursor (Gtk2::Gdk::Cursor->new ($ea->special_arrow));
105 } else { 106 } else {
106 $self->{map}->{window}->set_cursor (Gtk2::Gdk::Cursor->new ('GDK_LEFT_PTR')); 107 $self->{map}->{window}->set_cursor (Gtk2::Gdk::Cursor->new ('GDK_LEFT_PTR'));
107 } 108 }
109 delete $self->{ea_alt};
108 }); 110 });
109 111
110 $map->signal_connect (key_press_event => sub { 112 $map->signal_connect (key_press_event => sub {
111 my ($map, $event) = @_; 113 my ($map, $event) = @_;
112 114
156 158
157 if ((not $self->{draw_mode}) and $event->button != 2) { 159 if ((not $self->{draw_mode}) and $event->button != 2) {
158 160
159 my $ea = $self->ea; 161 my $ea = $self->ea;
160 162
161 $ea->begin ($map, $x, $y) 163 $ea->begin ($map, $x, $y, $self)
162 if $x >= 0 and $y >= 0 and $x < $map->{map}{width} and $y < $map->{map}{height}; 164 if $x >= 0 and $y >= 0 and $x < $map->{map}{width} and $y < $map->{map}{height};
163 165
164 $self->{draw_mode} = [$x, $y]; 166 $self->{draw_mode} = [$x, $y];
165 167
166 $ea->want_cursor 168 $ea->want_cursor
187 $X++ if $X < $x; 189 $X++ if $X < $x;
188 $X-- if $X > $x; 190 $X-- if $X > $x;
189 $Y++ if $Y < $y; 191 $Y++ if $Y < $y;
190 $Y-- if $Y > $y; 192 $Y-- if $Y > $y;
191 193
192 $ea->edit ($map, $X, $Y) 194 $ea->edit ($map, $X, $Y, $self)
193 if $X >= 0 and $Y >= 0 and $X < $map->{map}{width} and $Y < $map->{map}{height}; 195 if $X >= 0 and $Y >= 0 and $X < $map->{map}{width} and $Y < $map->{map}{height};
194 } 196 }
195 197
196 @{$self->{draw_mode}}[0,1] = ($X, $Y); 198 @{$self->{draw_mode}}[0,1] = ($X, $Y);
197 199
203 205
204 if ($self->{draw_mode}) { 206 if ($self->{draw_mode}) {
205 my ($x, $y) = $map->coord ($map->get_pointer); 207 my ($x, $y) = $map->coord ($map->get_pointer);
206 208
207 my $ea = $self->ea; 209 my $ea = $self->ea;
208 $ea->end ($map, $x, $y); 210 $ea->end ($map, $x, $y, $self);
209 211
210 delete $self->{draw_mode}; 212 delete $self->{draw_mode};
211 213
212 $ea->want_cursor 214 $ea->want_cursor
213 or $map->enable_tooltip; 215 or $map->enable_tooltip;
269sub save_map { 271sub save_map {
270 my ($self) = @_; 272 my ($self) = @_;
271 273
272 if ($self->{path}) { 274 if ($self->{path}) {
273 $self->{map}{map}->write_file ($self->{path}); 275 $self->{map}{map}->write_file ($self->{path});
276 quick_msg ($self, "saved to $self->{path}");
277 } else {
278 $self->save_map_as;
274 } 279 }
275} 280}
276 281
277sub save_map_as { 282sub save_map_as {
278 my ($self) = @_; 283 my ($self) = @_;
279 284
280 my $fc = $::MAINWIN->new_filechooser ('gce - save map', 1); 285 my $fc = $::MAINWIN->new_filechooser ('gce - save map', 1, $self->{path});
281 286
282 if ('ok' eq $fc->run) { 287 if ('ok' eq $fc->run) {
283 288
284 $::MAINWIN->{fc_last_folder} = $fc->get_current_folder; 289 $::MAINWIN->{fc_last_folder} = $fc->get_current_folder;
285 $::MAINWIN->{fc_last_folders}->{$self->{fc_last_folder}}++; 290 $::MAINWIN->{fc_last_folders}->{$self->{fc_last_folder}}++;
286 291
287 $self->{map}{map}->write_file ($self->{path} = $fc->get_filename); 292 $self->{map}{map}->write_file ($self->{path} = $fc->get_filename);
293 quick_msg ($self, "saved to $self->{path}");
288 } 294 }
289 295
290 $fc->destroy; 296 $fc->destroy;
291} 297}
292 298

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines