… | |
… | |
60 | callback => sub { $self->open_resize_map }, |
60 | callback => sub { $self->open_resize_map }, |
61 | accelerator => "<ctrl>R" |
61 | accelerator => "<ctrl>R" |
62 | }, |
62 | }, |
63 | ] |
63 | ] |
64 | }, |
64 | }, |
65 | |
65 | _Go => { |
|
|
66 | item_type => '<Branch>', |
|
|
67 | children => [ |
|
|
68 | "_Up" => { |
|
|
69 | callback => sub { $self->follow ('u') }, |
|
|
70 | accelerator => "<ctrl>U" |
|
|
71 | }, |
|
|
72 | "_Down" => { |
|
|
73 | callback => sub { $self->follow ('d') }, |
|
|
74 | accelerator => "<ctrl>D" |
|
|
75 | }, |
|
|
76 | "_Right" => { |
|
|
77 | callback => sub { $self->follow ('r') }, |
|
|
78 | accelerator => "<ctrl>R" |
|
|
79 | }, |
|
|
80 | "_Left" => { |
|
|
81 | callback => sub { $self->follow ('l') }, |
|
|
82 | accelerator => "<ctrl>L" |
|
|
83 | }, |
|
|
84 | ] |
|
|
85 | }, |
|
|
86 | _Help => { |
|
|
87 | item_type => '<Branch>', |
|
|
88 | children => [ |
|
|
89 | _Help => { |
|
|
90 | callback => sub { $::MAINWIN->show_help_window }, |
|
|
91 | accelerator => "<ctrl>H" |
|
|
92 | }, |
|
|
93 | ] |
|
|
94 | }, |
66 | ]; |
95 | ]; |
67 | |
96 | |
68 | my $men = |
97 | my $men = |
69 | Gtk2::SimpleMenu->new ( |
98 | Gtk2::SimpleMenu->new ( |
70 | menu_tree => $menu_tree, |
99 | menu_tree => $menu_tree, |
… | |
… | |
100 | my ($self) = @_; |
129 | my ($self) = @_; |
101 | |
130 | |
102 | $self->set_title ('gce - map editor'); |
131 | $self->set_title ('gce - map editor'); |
103 | $self->add (my $vb = Gtk2::VBox->new); |
132 | $self->add (my $vb = Gtk2::VBox->new); |
104 | |
133 | |
105 | $self->signal_connect (delete_event => sub { $self->delete }); |
134 | $self->signal_connect (delete_event => sub { $self->delete; 1 }); |
106 | |
135 | |
107 | $vb->pack_start (my $menu = $self->build_menu, 0, 1, 0); |
136 | $vb->pack_start (my $menu = $self->build_menu, 0, 1, 0); |
108 | |
137 | |
109 | $vb->pack_start (my $map = $self->{map} = Crossfire::MapWidget->new, 1, 1, 0); |
138 | $vb->pack_start (my $map = $self->{map} = Crossfire::MapWidget->new, 1, 1, 0); |
110 | |
139 | |
… | |
… | |
125 | |
154 | |
126 | my ($x, $y) = $map->coord ($map->get_pointer); |
155 | my ($x, $y) = $map->coord ($map->get_pointer); |
127 | for ([Control_L => sub { $self->{ea_alt} = $::MAINWIN->{edit_collection}{erase} }], |
156 | for ([Control_L => sub { $self->{ea_alt} = $::MAINWIN->{edit_collection}{erase} }], |
128 | [Alt_L => sub { $self->{ea_alt} = $::MAINWIN->{edit_collection}{pick} }], |
157 | [Alt_L => sub { $self->{ea_alt} = $::MAINWIN->{edit_collection}{pick} }], |
129 | [c => sub { $::MAINWIN->{edit_collection}{select}->copy }], |
158 | [c => sub { $::MAINWIN->{edit_collection}{select}->copy }], |
130 | [v => sub { $::MAINWIN->{edit_collection}{select}->paste ($x, $y) }], |
159 | [v => sub { $::MAINWIN->{edit_collection}{select}->paste ($map, $x, $y) }], |
131 | [n => sub { $::MAINWIN->{edit_collection}{select}->invoke }], |
160 | [n => sub { $::MAINWIN->{edit_collection}{select}->invoke }], |
132 | ) |
161 | ) |
133 | { |
162 | { |
134 | if ($kv == $Gtk2::Gdk::Keysyms{$_->[0]}) { |
163 | if ($kv == $Gtk2::Gdk::Keysyms{$_->[0]}) { |
135 | $_->[1]->(); |
164 | $_->[1]->(); |
… | |
… | |
256 | sub delete { |
285 | sub delete { |
257 | my ($self) = @_; |
286 | my ($self) = @_; |
258 | |
287 | |
259 | # check and modla dialog if "dirty" |
288 | # check and modla dialog if "dirty" |
260 | |
289 | |
|
|
290 | if ($self->{mapkey}) { |
|
|
291 | # XXX: This should be in a delete event handler in the MainWindow.pm... but it doesnt work |
|
|
292 | delete $::MAINWIN->{loaded_maps}->{$self->{mapkey}}; |
|
|
293 | } |
|
|
294 | |
261 | $self->destroy; |
295 | $self->destroy; |
262 | } |
296 | } |
263 | |
297 | |
264 | sub open_map { |
298 | sub open_map { |
265 | my ($self, $path) = @_; |
299 | my ($self, $path, $key) = @_; |
|
|
300 | |
|
|
301 | $self->{mapkey} = $key; |
266 | |
302 | |
267 | if (ref $path) { |
303 | if (ref $path) { |
268 | $self->{map}->set_map ($path); |
304 | $self->{map}->set_map ($path); |
269 | |
305 | |
270 | } else { |
306 | } else { |
… | |
… | |
328 | } elsif ($type eq 'label') { |
364 | } elsif ($type eq 'label') { |
329 | $table->attach_defaults (my $lbl = Gtk2::Label->new ($desc), 0, 1, $idx, $idx + 1); |
365 | $table->attach_defaults (my $lbl = Gtk2::Label->new ($desc), 0, 1, $idx, $idx + 1); |
330 | $edwid = Gtk2::Label->new ($self->{map}{map}{info}{$key}); |
366 | $edwid = Gtk2::Label->new ($self->{map}{map}{info}{$key}); |
331 | $table->attach_defaults ($edwid, 1, 2, $idx, $idx + 1); |
367 | $table->attach_defaults ($edwid, 1, 2, $idx, $idx + 1); |
332 | |
368 | |
|
|
369 | } elsif ($type eq 'check') { |
|
|
370 | $table->attach_defaults (my $lbl1 = Gtk2::Label->new ($desc), 0, 1, $idx, $idx + 1); |
|
|
371 | $table->attach_defaults (my $lbl = Gtk2::CheckButton->new, 1, 2, $idx, $idx + 1); |
|
|
372 | $lbl->set_active ($self->{map}{map}{info}{$key}); |
|
|
373 | $lbl->signal_connect (toggled => sub { |
|
|
374 | my ($lbl) = @_; |
|
|
375 | $self->{map}{map}{info}{$key} = $lbl->get_active * 1; |
|
|
376 | ($changecb || sub {})->($lbl->get_active); |
|
|
377 | }); |
|
|
378 | |
|
|
379 | } elsif ($type eq 'sep') { |
|
|
380 | $table->attach_defaults (my $lbl1 = Gtk2::HSeparator->new, 0, 2, $idx, $idx + 1); |
333 | } else { |
381 | } else { |
334 | $edwid = Gtk2::Label->new ("FOO"); |
382 | $edwid = Gtk2::Label->new ("FOO"); |
335 | } |
383 | } |
336 | } |
384 | } |
337 | |
385 | |
… | |
… | |
362 | } |
410 | } |
363 | |
411 | |
364 | $w->show_all; |
412 | $w->show_all; |
365 | } |
413 | } |
366 | |
414 | |
|
|
415 | sub follow { |
|
|
416 | my ($self, $dir) = @_; |
|
|
417 | |
|
|
418 | my %dir_to_path = ( |
|
|
419 | u => 'tile_path_1', |
|
|
420 | d => 'tile_path_3', |
|
|
421 | r => 'tile_path_2', |
|
|
422 | l => 'tile_path_4', |
|
|
423 | ); |
|
|
424 | |
|
|
425 | defined $dir_to_path{$dir} |
|
|
426 | or return; |
|
|
427 | my $map = $self->{map}{map}{info}{$dir_to_path{$dir}} |
|
|
428 | or return; |
|
|
429 | |
|
|
430 | $map = map2abs ($map, $self); |
|
|
431 | $::MAINWIN->open_map_editor ($map); |
|
|
432 | } |
|
|
433 | |
367 | sub open_map_prop { |
434 | sub open_map_prop { |
368 | my ($self) = @_; |
435 | my ($self) = @_; |
369 | |
436 | |
370 | |
437 | |
371 | my $w = Gtk2::Window->new ('toplevel'); |
438 | my $w = Gtk2::Window->new ('toplevel'); |
… | |
… | |
375 | $sw->set_policy ('automatic', 'automatic'); |
442 | $sw->set_policy ('automatic', 'automatic'); |
376 | $v->pack_start (my $t = Gtk2::Table->new (2, 10), 0, 0, 0); |
443 | $v->pack_start (my $t = Gtk2::Table->new (2, 10), 0, 0, 0); |
377 | |
444 | |
378 | my $i = 0; |
445 | my $i = 0; |
379 | for ( |
446 | for ( |
380 | [qw/name Name string/], |
447 | [qw/name Name string/], |
381 | [qw/region Region string/], |
448 | [qw/region Region string/], |
|
|
449 | [qw/enter_x Enter-x string/], |
|
|
450 | [qw/enter_y Enter-y string/], |
|
|
451 | [qw/reset_timeout Reset-timeout string/], |
|
|
452 | [qw/swap_time Swap-timeout string/], |
|
|
453 | [qw/x x sep/], |
382 | [qw/difficulty Difficulty string/], |
454 | [qw/difficulty Difficulty string/], |
|
|
455 | [qw/windspeed Windspeed string/], |
|
|
456 | [qw/pressure Pressure string/], |
|
|
457 | [qw/humid Humid string/], |
|
|
458 | [qw/temp Temp string/], |
|
|
459 | [qw/darkness Darkness string/], |
|
|
460 | [qw/sky Sky string/], |
|
|
461 | [qw/winddir Winddir string/], |
|
|
462 | [qw/x x sep/], |
383 | [qw/width Width label/], # sub { $self->{map}{map}->resize ($_[0], $self->{map}{map}{height}) }], |
463 | [qw/width Width label/], # sub { $self->{map}{map}->resize ($_[0], $self->{map}{map}{height}) }], |
384 | [qw/height Height label/],# sub { $self->{map}{map}->resize ($self->{map}{map}{width}, $_[0]) }], |
464 | [qw/height Height label/], # sub { $self->{map}{map}->resize ($self->{map}{map}{width}, $_[0]) }], |
|
|
465 | [qw/x x sep/], |
385 | [qw/msg Text text/], |
466 | [qw/msg Text text/], |
|
|
467 | [qw/maplore Maplore text/], |
|
|
468 | [qw/outdoor Outdoor check/], |
|
|
469 | [qw/unique Unique check/], |
|
|
470 | [qw/fixed_resettime Fixed-resettime check/], |
|
|
471 | [qw/x x sep/], |
386 | [qw/tile_path_1 Northpath string/], |
472 | [qw/tile_path_1 Northpath string/], |
387 | [qw/tile_path_2 Eastpath string/], |
473 | [qw/tile_path_2 Eastpath string/], |
388 | [qw/tile_path_3 Southpath string/], |
474 | [qw/tile_path_3 Southpath string/], |
389 | [qw/tile_path_4 Westpath string/], |
475 | [qw/tile_path_4 Westpath string/], |
390 | [qw/tile_path_5 Toppath string/], |
476 | [qw/tile_path_5 Toppath string/], |
391 | [qw/tile_path_6 Bottompath string/], |
477 | [qw/tile_path_6 Bottompath string/], |
392 | ) |
478 | ) |
393 | { |
479 | { |
394 | $self->_add_prop_entry ($t, $i++, @$_); |
480 | $self->_add_prop_entry ($t, $i++, @$_); |
395 | } |
481 | } |
396 | |
482 | |
397 | $w->show_all; |
483 | $w->show_all; |
398 | } |
484 | } |
399 | |
485 | |
400 | # 'info' => { |
|
|
401 | # 'windspeed' => '10', |
|
|
402 | # 'outdoor' => '1', |
|
|
403 | # 'width' => '20', |
|
|
404 | # 'pressure' => '8', |
|
|
405 | # 'test' => '', |
|
|
406 | # 'tile_path_2' => 'east', |
|
|
407 | # 'tile_path_3' => 'south', |
|
|
408 | # 'enter_y' => '2', |
|
|
409 | # 'tile_path_6' => 'bottom', |
|
|
410 | # 'enter_x' => '1', |
|
|
411 | # 'tile_path_5' => 'top', |
|
|
412 | # 'darkness' => '4', |
|
|
413 | # 'maplore' => '', |
|
|
414 | # 'sky' => '12', |
|
|
415 | # 'winddir' => '11', |
|
|
416 | # 'unique' => '1', |
|
|
417 | # 'msg' => 'Creator: CF Java FUCK Map Editor |
|
|
418 | #Date: 3/12/2006 |
|
|
419 | #', |
|
|
420 | # 'difficulty' => '3', |
|
|
421 | # 'humid' => '9', |
|
|
422 | # 'endmaplore' => '', |
|
|
423 | # 'fixed_resettime' => '1', |
|
|
424 | # 'name' => 'test', |
|
|
425 | # 'region' => 'REGION', |
|
|
426 | # 'height' => '40', |
|
|
427 | # 'reset_timeout' => '6', |
|
|
428 | # '_name' => 'map', |
|
|
429 | # 'swap_time' => '5', |
|
|
430 | # 'temp' => '7', |
|
|
431 | # 'tile_path_4' => 'west', |
|
|
432 | # 'tile_path_1' => 'north' |
|
|
433 | # }, |
|
|
434 | |
|
|
435 | |
|
|
436 | =head1 AUTHOR |
486 | =head1 AUTHOR |
437 | |
487 | |
438 | Marc Lehmann <schmorp@schmorp.de> |
488 | Marc Lehmann <schmorp@schmorp.de> |
439 | http://home.schmorp.de/ |
489 | http://home.schmorp.de/ |
440 | |
490 | |