… | |
… | |
82 | my $mapkey; |
82 | my $mapkey; |
83 | unless (ref $mapfile) { |
83 | unless (ref $mapfile) { |
84 | unless (File::Spec->file_name_is_absolute ($mapfile)) { |
84 | unless (File::Spec->file_name_is_absolute ($mapfile)) { |
85 | $mapfile = File::Spec->rel2abs ($mapfile); |
85 | $mapfile = File::Spec->rel2abs ($mapfile); |
86 | } |
86 | } |
87 | $mapkey = File::Spec->abs2rel ($mapfile, File::Spec->catfile ($Crossfire::LIB, 'maps')); |
87 | $mapkey = File::Spec->abs2rel ($mapfile, File::Spec->catfile ($::CFG->{MAPDIR})); |
88 | } |
88 | } |
89 | |
89 | |
90 | # XXX: last_map_window is a dirty trick to get the position and size |
90 | # XXX: last_map_window is a dirty trick to get the position and size |
91 | # for save layout |
91 | # for save layout |
92 | |
92 | |
… | |
… | |
128 | main::set_pos_and_size ($w, $main::CFG->{stack_view}, 150, 250); |
128 | main::set_pos_and_size ($w, $main::CFG->{stack_view}, 150, 250); |
129 | |
129 | |
130 | $w->show_all; |
130 | $w->show_all; |
131 | } |
131 | } |
132 | |
132 | |
|
|
133 | sub show_editor_properties { |
|
|
134 | my ($self) = @_; |
|
|
135 | |
|
|
136 | return if $self->{prop_edit}; |
|
|
137 | |
|
|
138 | my $w = $self->{prop_edit} = Gtk2::Window->new; |
|
|
139 | $w->set_title ("gce - properties"); |
|
|
140 | $w->add (my $t = Gtk2::Table->new (2, 4)); |
|
|
141 | $t->attach_defaults (my $lbl1 = Gtk2::Label->new ("CROSSFIRE_LIBDIR"), 0, 1, 0, 1); |
|
|
142 | $t->attach_defaults (my $lib = Gtk2::Entry->new, 1, 2, 0, 1); |
|
|
143 | $lib->set_text ($::CFG->{LIBDIR}); |
|
|
144 | $t->attach_defaults (my $lbl2 = Gtk2::Label->new ("Map path"), 0, 1, 1, 2); |
|
|
145 | $t->attach_defaults (my $map = Gtk2::Entry->new, 1, 2, 1, 2); |
|
|
146 | $map->set_text ($::CFG->{MAPDIR}); |
|
|
147 | $t->attach_defaults (my $save = Gtk2::Button->new ('save'), 0, 2, 2, 3); |
|
|
148 | $save->signal_connect (clicked => sub { |
|
|
149 | $::CFG->{LIBDIR} = $lib->get_text; |
|
|
150 | $::CFG->{MAPDIR} = $map->get_text; |
|
|
151 | Crossfire::set_libdir ($::CFG->{LIBDIR}); |
|
|
152 | Crossfire::load_archetypes; |
|
|
153 | Crossfire::load_tilecache; |
|
|
154 | main::write_cfg ("$Crossfire::VARDIR/gceconfig"); |
|
|
155 | $w->destroy; |
|
|
156 | }); |
|
|
157 | $t->attach_defaults (my $close = Gtk2::Button->new ('close'), 0, 2, 3, 4); |
|
|
158 | $close->signal_connect (clicked => sub { $w->destroy }); |
|
|
159 | |
|
|
160 | $w->signal_connect (delete_event => sub { delete $self->{prop_edit}; 0 }); |
|
|
161 | |
|
|
162 | main::set_pos_and_size ($w, $main::CFG->{prop_edit}, 200, 200); |
|
|
163 | |
|
|
164 | $w->show_all; |
|
|
165 | } |
|
|
166 | |
133 | sub show_attr_editor { |
167 | sub show_attr_editor { |
134 | my ($self) = @_; |
168 | my ($self) = @_; |
135 | |
169 | |
136 | return if $self->{attr_edit}; |
170 | return if $self->{attr_edit}; |
137 | |
171 | |
… | |
… | |
202 | accelerator => '<ctrl>O' |
236 | accelerator => '<ctrl>O' |
203 | }, |
237 | }, |
204 | "_Save Layout" => { |
238 | "_Save Layout" => { |
205 | callback => sub { $self->save_layout }, |
239 | callback => sub { $self->save_layout }, |
206 | accelerator => '<ctrl>L' |
240 | accelerator => '<ctrl>L' |
|
|
241 | }, |
|
|
242 | "_Properties" => { |
|
|
243 | callback => sub { $self->show_editor_properties }, |
|
|
244 | accelerator => "<ctrl>T" |
207 | }, |
245 | }, |
208 | _Quit => { |
246 | _Quit => { |
209 | callback => sub { Gtk2->main_quit }, |
247 | callback => sub { Gtk2->main_quit }, |
210 | accelerator => '<ctrl>Q' |
248 | accelerator => '<ctrl>Q' |
211 | } |
249 | } |
… | |
… | |
416 | $title ||= 'gce - open map'; |
454 | $title ||= 'gce - open map'; |
417 | my $fc = new Gtk2::FileChooserDialog ( |
455 | my $fc = new Gtk2::FileChooserDialog ( |
418 | $title, undef, $save ? 'save' : 'open', 'gtk-cancel' => 'cancel', 'gtk-ok' => 'ok' |
456 | $title, undef, $save ? 'save' : 'open', 'gtk-cancel' => 'cancel', 'gtk-ok' => 'ok' |
419 | ); |
457 | ); |
420 | |
458 | |
421 | $fc->add_shortcut_folder ("$Crossfire::LIB/maps") if -d "$Crossfire::LIB/maps"; |
459 | $fc->add_shortcut_folder ($::CFG->{MAPDIR}) if -d $::CFG->{MAPDIR}; |
422 | $fc->add_shortcut_folder ($_) for grep { $_ && ($_ ne '') } keys %{$self->{fc_last_folders}}; |
460 | $fc->add_shortcut_folder ($_) for grep { $_ && ($_ ne '') } keys %{$self->{fc_last_folders}}; |
423 | $fc->set_current_folder ($self->{fc_last_folder} || "$Crossfire::LIB/maps"); |
461 | $fc->set_current_folder ($self->{fc_last_folder} || $::CFG->{MAPDIR}); |
424 | |
462 | |
425 | if ($filename) { |
463 | if ($filename) { |
426 | $fc->set_filename ($filename); |
464 | $fc->set_filename ($filename); |
427 | } |
465 | } |
428 | |
466 | |