ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/gde/GCE/MainWindow.pm
Revision: 1.78
Committed: Sun Aug 12 15:25:08 2007 UTC (16 years, 10 months ago) by elmex
Branch: MAIN
Changes since 1.77: +8 -6 lines
Log Message:
fix for MAPDIR in last folder problem?

File Contents

# User Rev Content
1 elmex 1.1 package GCE::MainWindow;
2    
3     =head1 NAME
4    
5     GCE::MainWindow - the main window class for gce
6    
7     =cut
8    
9 elmex 1.58 use Cwd qw/abs_path getcwd/;
10 elmex 1.1 use Gtk2;
11     use Gtk2::Gdk::Keysyms;
12 elmex 1.2 use Gtk2::SimpleMenu;
13 root 1.7
14     use Crossfire;
15 elmex 1.32 use Crossfire::Map;
16 root 1.7 use Crossfire::MapWidget;
17    
18 elmex 1.2 use GCE::AttrEdit;
19 elmex 1.13 use GCE::MapEditor;
20 elmex 1.15 use GCE::StackView;
21 elmex 1.17 use GCE::EditAction;
22     use GCE::PickWindow;
23 elmex 1.2
24 elmex 1.53 use Glib::Object::Subclass
25 elmex 1.13 Gtk2::Window;
26 elmex 1.2
27 elmex 1.28 use GCE::Util;
28 elmex 1.54 use GCE::DragHelper;
29 elmex 1.28
30 elmex 1.2 use strict;
31    
32 elmex 1.18 # XXX: make a recursive call from save_layout to all (interesting) sub-widgets
33 elmex 1.17 sub save_layout {
34     my ($self) = @_;
35    
36 elmex 1.58 # $main::CFG->{attr_edit_on} = exists $self->{attr_edit} ? 1 : 0;
37 elmex 1.17 $main::CFG->{stack_view_on} = exists $self->{sv} ? 1 : 0;
38     $main::CFG->{picker_on} = exists $self->{last_pick_window} ? 1 : 0;
39     $main::CFG->{main_window} = main::get_pos_and_size ($self);
40     $main::CFG->{stack_view} = main::get_pos_and_size ($self->{sv_win}) if $self->{sv_win};
41     $main::CFG->{attr_view} = main::get_pos_and_size ($self->{attr_edit_win}) if $self->{attr_edit_win};
42    
43 elmex 1.70 if ($self->{last_map_window}) {
44     $main::CFG->{map_window} = main::get_pos_and_size ($self->{last_map_window});
45     $self->{last_map_window}->save_layout ();
46     }
47 elmex 1.69
48 elmex 1.75 $self->{worldmap_coord_query}->save_layout ()
49     if $self->{worldmap_coord_query};
50 elmex 1.73
51 elmex 1.37 $main::CFG->{last_folders} = $self->{fc_last_folders};
52    
53 elmex 1.17 $main::CFG->{open_pickers} = [];
54    
55     for (@{$self->{open_pick_windows}}) {
56    
57     next unless defined $_;
58    
59     push @{$main::CFG->{open_pickers}}, {
60     p_and_s => main::get_pos_and_size ($_),
61     selection => $_->{last_selection}
62     };
63     }
64    
65 elmex 1.59 $self->{attr_edit}->save_layout;
66    
67 root 1.26 main::write_cfg ("$Crossfire::VARDIR/gceconfig");
68 elmex 1.17 }
69    
70     sub load_layout {
71     my ($self) = @_;
72    
73 elmex 1.37 $self->{fc_last_folders} = $main::CFG->{last_folders};
74    
75 elmex 1.58 # $main::CFG->{attr_edit_on}
76     # and $self->show_attr_editor;
77 elmex 1.17
78     $main::CFG->{stack_view_on}
79     and $self->show_stack_view;
80    
81     for (@{$main::CFG->{open_pickers}}) {
82     $self->open_pick_window ($_);
83     }
84 elmex 1.59
85     $self->{attr_edit}->load_layout;
86 elmex 1.17 }
87    
88     sub open_map_editor {
89     my ($self, $mapfile) = @_;
90    
91 elmex 1.44 my $mapkey;
92 elmex 1.39 unless (ref $mapfile) {
93 elmex 1.58 # unless (File::Spec->file_name_is_absolute ($mapfile)) {
94     # $mapfile = File::Spec->rel2abs ($mapfile);
95     # }
96     $mapkey = abs_path ($mapfile);
97 elmex 1.76 # File::Spec->abs2rel ($mapfile, File::Spec->catfile ($::MAPDIR));
98 elmex 1.58 } else {
99     $mapkey = "$mapfile";
100 elmex 1.38 }
101    
102 elmex 1.17 # XXX: last_map_window is a dirty trick to get the position and size
103     # for save layout
104    
105 elmex 1.58 if (defined $self->{loaded_maps}->{$mapkey}) {
106     $self->{loaded_maps}->{$mapkey}->get_toplevel->present;
107     return;
108 elmex 1.38 }
109    
110 elmex 1.17 my $w = $self->{last_map_window} = GCE::MapEditor->new;
111 root 1.25
112 elmex 1.53 $self->{editors}->{$w} = $w;
113    
114     $w->signal_connect (destroy => sub {
115     my ($w) = @_;
116 elmex 1.67 $w->close_windows;
117 elmex 1.53 delete $self->{loaded_maps}->{$w->{mapkey}};
118     delete $self->{editors}->{$w};
119     0;
120     });
121    
122 elmex 1.58 $self->{loaded_maps}->{$mapkey} = $w;
123 elmex 1.38
124 elmex 1.72 eval { $w->open_map ($mapfile, $mapkey) };
125     if ($@) {
126     quick_msg ($self, "$@", 1);
127     $w->close_windows;
128     delete $self->{loaded_maps}->{$w->{mapkey}};
129     delete $self->{editors}->{$w};
130     $w->destroy;
131     return;
132     }
133 elmex 1.17
134 elmex 1.54 $w->set_edit_tool ($self->{sel_editaction});
135    
136 elmex 1.17 $w->show_all;
137     }
138    
139 elmex 1.47 sub show_help_window {
140     my ($self) = @_;
141    
142     return if defined $self->{help_win};
143 elmex 1.51 require Gtk2::Ex::PodViewer;
144 elmex 1.47 my $w = $self->{help_win} = Gtk2::Window->new;
145 elmex 1.66 $w->set_title ("gcrossedit - help");
146 elmex 1.47 $w->set_default_size (500, 300);
147 elmex 1.56 $w->signal_connect (destroy => sub {
148 elmex 1.53 $self->{help_win}->hide; $self->{help_win} = undef;
149     0
150     });
151 elmex 1.47 $w->add (my $sw = Gtk2::ScrolledWindow->new);
152 elmex 1.51 $sw->add (my $h = Gtk2::Ex::PodViewer->new);
153 elmex 1.47 $h->load_string ($::DOCUMENTATION);
154     $w->show_all;
155     }
156    
157 elmex 1.17 sub show_stack_view {
158 elmex 1.15 my ($self) = @_;
159    
160     return if defined $self->{sv};
161    
162 elmex 1.17 my $w = $self->{sv_win} = Gtk2::Window->new ('toplevel');
163 elmex 1.66 $w->set_title ('gcrossedit - stack view');
164 elmex 1.56 $w->signal_connect (destroy => sub { delete $self->{sv}; 0 });
165 elmex 1.15 $w->add ($self->{sv} = GCE::StackView->new);
166 elmex 1.17
167 elmex 1.30 main::set_pos_and_size ($w, $main::CFG->{stack_view}, 150, 250);
168 elmex 1.17
169 elmex 1.15 $w->show_all;
170     }
171    
172 elmex 1.46 sub show_editor_properties {
173     my ($self) = @_;
174    
175     return if $self->{prop_edit};
176    
177     my $w = $self->{prop_edit} = Gtk2::Window->new;
178 elmex 1.66 $w->set_title ("gcrossedit - preferences");
179 elmex 1.74 $w->add (my $t = Gtk2::Table->new (2, 5));
180 elmex 1.68 $t->attach_defaults (my $lbl1 = Gtk2::Label->new ("LIBDIR"), 0, 1, 0, 1);
181 elmex 1.46 $t->attach_defaults (my $lib = Gtk2::Entry->new, 1, 2, 0, 1);
182     $lib->set_text ($::CFG->{LIBDIR});
183 elmex 1.68 $t->attach_defaults (my $lbl2 = Gtk2::Label->new ("MAPDIR"), 0, 1, 1, 2);
184 elmex 1.46 $t->attach_defaults (my $map = Gtk2::Entry->new, 1, 2, 1, 2);
185     $map->set_text ($::CFG->{MAPDIR});
186 elmex 1.74 $t->attach_defaults (my $lbl1 = Gtk2::Label->new ("Username"), 0, 1, 2, 3);
187     $t->attach_defaults (my $usern = Gtk2::Entry->new, 1, 2, 2, 3);
188     $usern->set_text ($::CFG->{username});
189     $t->attach_defaults (my $save = Gtk2::Button->new ('save'), 0, 2, 3, 4);
190 elmex 1.46 $save->signal_connect (clicked => sub {
191 elmex 1.74 $::CFG->{LIBDIR} = $lib->get_text;
192     $::CFG->{MAPDIR} = $map->get_text;
193     $::LIBDIR = $::CFG->{LIBDIR} if $::CFG->{LIBDIR};
194     $::MAPDIR = $::CFG->{MAPDIR} if $::CFG->{MAPDIR};
195     $::CFG->{username} = $usern->get_text;
196     Crossfire::set_libdir ($::LIBDIR);
197 elmex 1.46 Crossfire::load_archetypes;
198     Crossfire::load_tilecache;
199     main::write_cfg ("$Crossfire::VARDIR/gceconfig");
200     $w->destroy;
201     });
202 elmex 1.74 $t->attach_defaults (my $close = Gtk2::Button->new ('close'), 0, 2, 4, 5);
203 elmex 1.46 $close->signal_connect (clicked => sub { $w->destroy });
204    
205 elmex 1.56 $w->signal_connect (destroy => sub { delete $self->{prop_edit}; 0 });
206 elmex 1.46
207     main::set_pos_and_size ($w, $main::CFG->{prop_edit}, 200, 200);
208    
209     $w->show_all;
210     }
211    
212 elmex 1.15 sub show_attr_editor {
213     my ($self) = @_;
214    
215     my $w = $self->{attr_edit_win} = Gtk2::Window->new;
216 elmex 1.66 $w->set_title ("gcrossedit - edit attrs");
217 elmex 1.15 $w->add ($self->{attr_edit} = GCE::AttrEdit->new);
218 elmex 1.17
219 elmex 1.64 main::set_pos_and_size ($w, $main::CFG->{attr_view}, 400, 300, 250, 0);
220 elmex 1.17
221 elmex 1.15 $w->show_all;
222     }
223    
224     sub update_attr_editor {
225 elmex 1.61 my ($self, $ar) = @_;
226    
227     if (ref ($ar) ne 'GCE::ArchRef') { require Carp; Carp::confess ("$ar no ARCHREF!") }
228 elmex 1.15
229 elmex 1.58 $self->{attr_edit}
230     or die "SERIOUS BUG: Couldn't find attribut editor!";
231 elmex 1.15
232 elmex 1.61 $self->{attr_edit}->set_arch ($ar, 1);
233 elmex 1.66 $self->{attr_edit_win}->set_title ("gcrossedit - edit " . $ar->longname);
234 elmex 1.15 }
235    
236     sub update_stack_view {
237 elmex 1.17 my ($self, $mapedit, $x, $y) = @_;
238 elmex 1.15
239     return unless $self->{sv};
240    
241 elmex 1.17 $self->{sv}->set_stack ($mapedit, $x, $y);
242 elmex 1.62
243 elmex 1.15 }
244    
245 elmex 1.17 sub open_pick_window {
246     my ($self, $layout) = @_;
247    
248 root 1.29 # XXX: Yes, also fix this, save _every_ pick window and their positions and their
249 elmex 1.17 # selection
250     my $p = GCE::PickWindow->new ();
251 elmex 1.15
252 elmex 1.17 push @{$self->{open_pick_windows}}, $p;
253    
254     my $idx = (@{$self->{open_pick_windows}}) - 1;
255 elmex 1.15
256 elmex 1.17 $p->signal_connect ('delete-event' => sub {
257     $self->{open_pick_windows}->[$idx] = undef;
258     });
259 elmex 1.10
260 elmex 1.17 if ($layout) {
261 elmex 1.30 main::set_pos_and_size ($p, $layout->{p_and_s}, 200, 200);
262 elmex 1.17 }
263 elmex 1.10
264 elmex 1.17 $p->show_all;
265 elmex 1.10
266 elmex 1.17 $p->set_selection ($layout->{selection});
267 elmex 1.10 }
268    
269 elmex 1.13 sub build_menu {
270 elmex 1.1 my ($self) = @_;
271    
272 elmex 1.2 my $menu_tree = [
273     _File => {
274     item_type => '<Branch>',
275     children => [
276     _New => {
277     callback => sub { $self->new_cb },
278     accelerator => '<ctrl>N'
279     },
280     _Open => {
281     callback => sub { $self->open_cb },
282     accelerator => '<ctrl>O'
283     },
284 elmex 1.71 'Open special' => {
285     item_type => '<Branch>',
286     children => [
287     "world map at"=> {
288     callback => sub { $self->open_worldmap_cb },
289     },
290     ]
291     },
292 elmex 1.17 "_Save Layout" => {
293     callback => sub { $self->save_layout },
294     accelerator => '<ctrl>L'
295     },
296 elmex 1.52 "_Preferences" => {
297 elmex 1.46 callback => sub { $self->show_editor_properties },
298     accelerator => "<ctrl>T"
299     },
300 elmex 1.49 _Quit => {
301 elmex 1.2 callback => sub { Gtk2->main_quit },
302     accelerator => '<ctrl>Q'
303 elmex 1.47 },
304 elmex 1.2 ]
305     },
306 root 1.24 _Dialogs => {
307 elmex 1.2 item_type => '<Branch>',
308     children => [
309 elmex 1.17 "_Picker" => {
310     callback => sub { $self->open_pick_window },
311     accelerator => "<ctrl>P"
312     },
313     "_Stack View" => {
314     callback => sub { $self->show_stack_view },
315     accelerator => "<ctrl>V"
316     },
317 elmex 1.2 ]
318 elmex 1.47 },
319 elmex 1.49 _Help => {
320     item_type => '<Branch>',
321     children => [
322 elmex 1.50 _Manual => {
323 elmex 1.49 callback => sub { $self->show_help_window },
324     accelerator => "<ctrl>H"
325     },
326     ]
327     },
328 elmex 1.2 ];
329    
330 elmex 1.13 my $men =
331     Gtk2::SimpleMenu->new (
332     menu_tree => $menu_tree,
333     default_callback => \&default_cb,
334     );
335 elmex 1.10
336 elmex 1.2 $self->add_accel_group ($men->{accel_group});
337    
338 elmex 1.13 return $men->{widget};
339     }
340 elmex 1.10
341 elmex 1.17 sub add_button {
342     my ($self, $table, $plcinfo, $lbl, $cb) = @_;
343    
344     my ($lx, $ly) = @{$plcinfo->{next}};
345    
346     unless ($lx < $plcinfo->{width}) {
347    
348     $ly++;
349     $lx = 0;
350     }
351    
352     $ly < $plcinfo->{height}
353     or die "too many buttons, make table bigger!";
354    
355 elmex 1.42 $table->attach_defaults (my $btn = Gtk2::Button->new_with_mnemonic ($lbl), $lx, $lx + 1, $ly, $ly + 1);
356 elmex 1.17 $btn->signal_connect (clicked => $cb);
357    
358     $plcinfo->{next} = [$lx + 1, $ly];
359     }
360    
361     sub build_buttons {
362     my ($self) = @_;
363    
364 elmex 1.38 my $tbl = Gtk2::Table->new (2, 4);
365     my $plcinfo = { width => 2, height => 4, next => [0, 0] };
366 elmex 1.17
367 elmex 1.38 $self->{edit_collection}{pick} = GCE::EditAction::Pick->new;
368     $self->{edit_collection}{place} = GCE::EditAction::Place->new;
369     $self->{edit_collection}{erase} = GCE::EditAction::Erase->new;
370     $self->{edit_collection}{select} = GCE::EditAction::Select->new;
371     $self->{edit_collection}{perl} = GCE::EditAction::Perl->new;
372 elmex 1.63 $self->{edit_collection}{connect} = GCE::EditAction::Connect->new;
373 elmex 1.38 $self->{edit_collection}{followexit} = GCE::EditAction::FollowExit->new;
374 elmex 1.17
375 elmex 1.33 $self->set_edit_tool ('pick');
376 elmex 1.28
377 elmex 1.42 $self->add_button ($tbl, $plcinfo, "P_ick", sub { $self->set_edit_tool ('pick') });
378     $self->add_button ($tbl, $plcinfo, "_Place", sub { $self->set_edit_tool ('place') });
379     $self->add_button ($tbl, $plcinfo, "_Erase", sub { $self->set_edit_tool ('erase') });
380     $self->add_button ($tbl, $plcinfo, "_Select", sub { $self->set_edit_tool ('select') });
381     $self->add_button ($tbl, $plcinfo, "Eva_l", sub { $self->set_edit_tool ('perl') });
382 elmex 1.63 $self->add_button ($tbl, $plcinfo, "Connec_t", sub { $self->set_edit_tool ('connect') });
383 elmex 1.42 $self->add_button ($tbl, $plcinfo, "_Follow Exit", sub { $self->set_edit_tool ('followexit') });
384 elmex 1.33
385     return $tbl;
386     }
387    
388     sub set_edit_tool {
389     my ($self, $name) = @_;
390    
391     if ($name eq 'pick') {
392 elmex 1.28 $self->update_edit_tool ($self->{edit_collection}{pick}, "Pick");;
393 elmex 1.33 } elsif ($name eq 'place') {
394 elmex 1.28 $self->update_edit_tool ($self->{edit_collection}{place}, "Place");;
395 elmex 1.33 } elsif ($name eq 'erase') {
396 elmex 1.28 $self->update_edit_tool ($self->{edit_collection}{erase}, "Erase");;
397 elmex 1.34 } elsif ($name eq 'select') {
398     $self->update_edit_tool ($self->{edit_collection}{select}, "Select");;
399 elmex 1.57 $self->{edit_collection}{select}->update_overlay;
400 elmex 1.35 } elsif ($name eq 'perl') {
401     $self->update_edit_tool ($self->{edit_collection}{perl}, "Eval");;
402 elmex 1.63 } elsif ($name eq 'connect') {
403     $self->update_edit_tool ($self->{edit_collection}{connect}, "Connect");;
404 elmex 1.38 } elsif ($name eq 'followexit') {
405     $self->update_edit_tool ($self->{edit_collection}{followexit}, "Follow Exit");;
406 elmex 1.33 }
407 elmex 1.17 }
408 elmex 1.10
409 elmex 1.28 sub update_edit_tool {
410     my ($self, $tool, $name) = @_;
411    
412 elmex 1.57 for (values %{$self->{loaded_maps}}) {
413     $_->{map}->overlay ('selection')
414     }
415    
416 elmex 1.28 $self->{edit_tool}->set_text ($name);
417     $self->{sel_editaction} = $tool;
418    
419     my $widget = $tool->tool_widget;
420    
421     for ($self->{edit_tool_cont}->get_children) {
422     $_->hide;
423     $self->{edit_tool_cont}->remove ($_);
424     }
425    
426 elmex 1.53 $_->set_edit_tool ($self->{sel_editaction}) for (values %{$self->{editors}});
427    
428 elmex 1.28 defined $widget or return;
429    
430     $self->{edit_tool_cont}->add ($widget);
431     $widget->show_all;
432     }
433    
434     sub update_pick_view {
435     my ($self, $arch) = @_;
436    
437     defined $arch->{_face}
438     or $arch = $Crossfire::ARCH{$arch->{_name}};
439    
440     fill_pb_from_arch ($self->{pick_view_pb}, $arch);
441     $self->{pick_view_img}->set_from_pixbuf ($self->{pick_view_pb});
442    
443 elmex 1.33 $self->{pick_view_btn}->set_label ($arch->{_name});
444 elmex 1.28 }
445    
446 elmex 1.13 sub INIT_INSTANCE {
447     my ($self) = @_;
448 elmex 1.10
449 root 1.24 $::MAINWIN = $self;
450 elmex 1.15
451 elmex 1.66 $self->set_title ("gcrossedit - toolbox");
452 elmex 1.10
453 elmex 1.28 $self->{edit_tool} = Gtk2::Label->new;
454     $self->{edit_tool_cont} = Gtk2::VBox->new;
455    
456 elmex 1.13 $self->add (my $vb = Gtk2::VBox->new);
457     $vb->pack_start ($self->build_menu, 0, 1, 0);
458 elmex 1.28 $vb->pack_start (my $tbl = $self->build_buttons, 0, 1, 0);
459    
460     $vb->pack_start (Gtk2::HSeparator->new, 0, 1, 0);
461     $vb->pack_start ($self->{edit_tool}, 0, 1, 0);
462    
463     $vb->pack_start (Gtk2::HSeparator->new, 0, 1, 0);
464 elmex 1.35 $vb->pack_start ($self->{edit_tool_cont}, 1, 1, 0);
465 elmex 1.10
466 elmex 1.13 # XXX:load $ARGV _cleanly_?
467 root 1.27 $self->open_map_editor ($_)
468     for @ARGV;
469 root 1.11
470 elmex 1.13 $self->signal_connect ('delete-event' => sub {
471     Gtk2->main_quit;
472 elmex 1.10 });
473 elmex 1.17
474 elmex 1.30 ::set_pos_and_size ($self, $main::CFG->{main_window}, 150, 200, 0, 0);
475 elmex 1.58
476    
477     $self->show_attr_editor;
478 elmex 1.2 }
479    
480     sub new_cb {
481     my ($self) = @_;
482 elmex 1.32
483     my $w = Gtk2::Window->new ('toplevel');
484     my $width = [width => 20];
485     my $height = [height => 20];
486     $w->add (my $tbl = Gtk2::Table->new (2, 3));
487     add_table_widget ($tbl, 0, $width, 'string');
488     add_table_widget ($tbl, 1, $height, 'string');
489     add_table_widget ($tbl, 2, 'new', 'button', sub {
490     if ($width->[1] > 0 and $height->[1] > 0) {
491     my $map = Crossfire::Map->new ($width->[1], $height->[1]);
492 elmex 1.69 $map->{info}->{width} = $width->[1];
493     $map->{info}->{height} = $height->[1];
494 elmex 1.33 $map->resize ($width->[1], $height->[1]);
495 elmex 1.32 $self->open_map_editor ($map);
496     }
497     $w->destroy;
498     1;
499     });
500     add_table_widget ($tbl, 3, 'close', 'button', sub { $w->destroy });
501     $w->show_all;
502 elmex 1.2 }
503    
504 root 1.25 sub new_filechooser {
505 elmex 1.37 my ($self, $title, $save, $filename) = @_;
506 elmex 1.2
507 elmex 1.66 $title ||= 'gcrossedit - open map';
508 root 1.25 my $fc = new Gtk2::FileChooserDialog (
509 elmex 1.33 $title, undef, $save ? 'save' : 'open', 'gtk-cancel' => 'cancel', 'gtk-ok' => 'ok'
510 elmex 1.13 );
511    
512 elmex 1.78 my @shortcut_folders =
513     grep { $_ && ($_ ne '') && -e $_ } keys %{$self->{fc_last_folders}};
514 elmex 1.76
515 elmex 1.78 $fc->add_shortcut_folder ($_) for @shortcut_folders;
516    
517     unless (grep { $::MAPDIR eq $_ } @shortcut_folders) {
518     $fc->add_shortcut_folder ($::MAPDIR)
519     if -d $::MAPDIR;
520     }
521 elmex 1.76
522 elmex 1.55 $fc->set_current_folder (getcwd);
523 elmex 1.2
524 elmex 1.37 if ($filename) {
525     $fc->set_filename ($filename);
526     }
527    
528 root 1.25 $fc
529     }
530    
531 elmex 1.71 sub new_coord_query {
532 elmex 1.75 my ($self, $finishcb) = @_;
533 elmex 1.71
534 elmex 1.75 my $coordhash = { x => 105, y => 115, worldmap => 1, overlay => 0 };
535 elmex 1.71 my $diag = GCE::HashDialogue->new;
536 elmex 1.75 $self->{"worldmap_coord_query"} = $diag;
537 elmex 1.73 $diag->signal_connect (destroy => sub {
538 elmex 1.75 delete $self->{"worldmap_coord_query"};
539 elmex 1.73 });
540 elmex 1.71 $diag->init (
541 elmex 1.75 layout_name => 'worldmap_coord_query',
542     info => "Open worldmap at ...",
543 elmex 1.71 dialog_default_size => [ 200, 200, 200, 0 ],
544     title => 'Worldmap coordinate entry',
545     ref_hash => $coordhash,
546     dialog => [
547 elmex 1.77 [x => 'X Coordinate' => 'spin', sub { (0, 999, 1) }],
548     [y => 'Y Coordinate' => 'spin', sub { (0, 999, 1) }],
549 elmex 1.75 [worldmap => 'Open worldmap' => 'check'],
550     [overlay => 'Open overlay (CF+)' => 'check'],
551 elmex 1.71 ],
552     save_button_label => 'open',
553     save_cb => sub {
554 elmex 1.75 $finishcb->($_[0]);
555 elmex 1.71 }
556     );
557     $diag->show_all;
558     }
559    
560     sub open_worldmap_cb {
561 elmex 1.75 my ($self) = @_;
562 elmex 1.71
563 elmex 1.75 $self->new_coord_query (sub {
564     my ($info) = @_;
565     my ($x, $y) = ($info->{x}, $info->{y});
566     my ($worldmap, $overlay) = ($info->{worldmap}, $info->{overlay});
567 elmex 1.76 $self->open_map_editor ($::MAPDIR . "/world/world_$x\_$y")
568 elmex 1.75 if $worldmap;
569 elmex 1.76 $self->open_map_editor ($::MAPDIR . "/world-overlay/world_$x\_$y")
570 elmex 1.75 if $overlay;
571 elmex 1.71 });
572     }
573    
574 root 1.25 sub open_cb {
575     my ($self) = @_;
576    
577     my $fc = $self->new_filechooser;
578    
579 elmex 1.2 if ('ok' eq $fc->run) {
580 elmex 1.13
581 elmex 1.10 $self->{fc_last_folder} = $fc->get_current_folder;
582 elmex 1.13 $self->{fc_last_folders}->{$self->{fc_last_folder}}++;
583 elmex 1.17
584     $self->open_map_editor ($fc->get_filename);
585 elmex 1.2 }
586    
587     $fc->destroy;
588     }
589    
590 elmex 1.17 sub get_pick {
591     my ($self) = @_;
592    
593 elmex 1.58 $self->{attr_edit}
594     or die "Couldn't find attribute editor! SERIOUS BUG!";
595    
596 elmex 1.17 # XXX: This is just to make sure that this function always returns something
597 elmex 1.61
598     my $ar = $self->{attr_edit}->get_arch;
599     return { _name => 'platinacoin' } unless defined $ar;
600     return $ar->getarch || { _name => 'platinacoin' };
601 elmex 1.17 }
602    
603 elmex 1.1 =head1 AUTHOR
604    
605     Marc Lehmann <schmorp@schmorp.de>
606     http://home.schmorp.de/
607    
608     Robin Redeker <elmex@ta-sa.org>
609     http://www.ta-sa.org/
610    
611     =cut
612     1;
613