1 | #!/usr/bin/python |
---|
2 | |
---|
3 | # This file is part of PARPG. |
---|
4 | # PARPG is free software: you can redistribute it and/or modify |
---|
5 | # it under the terms of the GNU General Public License as published by |
---|
6 | # the Free Software Foundation, either version 3 of the License, or |
---|
7 | # (at your option) any later version. |
---|
8 | # |
---|
9 | # PARPG is distributed in the hope that it will be useful, |
---|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
12 | # GNU General Public License for more details. |
---|
13 | # |
---|
14 | # You should have received a copy of the GNU General Public License |
---|
15 | # along with PARPG. If not, see <http://www.gnu.org/licenses/>. |
---|
16 | |
---|
17 | import os |
---|
18 | import sys |
---|
19 | |
---|
20 | """ |
---|
21 | This program is a hack. To be able to hook into the FIFE map editor load and |
---|
22 | save functionality we have to change the import path. It runs the FIFE |
---|
23 | editor such that our custom loaders and savers are used instead of the stock |
---|
24 | FIFE ones. Ideally the FIFE editor could be extended to support custom loaders |
---|
25 | and savers so we don't have to resort to tricking the editor. :) |
---|
26 | """ |
---|
27 | |
---|
28 | if __name__ == '__main__': |
---|
29 | # Either FIFE or the editor do not like being passed an absolute |
---|
30 | # path. Maybe a bug? We have to force paths relative to the parpg |
---|
31 | # directory. This also assumes that the parpg directory is at the same |
---|
32 | # level as the FIFE editor. :P |
---|
33 | parpg_path = os.path.split(os.path.realpath(sys.argv[0]))[0] |
---|
34 | parpg_dir = parpg_path.split('/')[-1] |
---|
35 | |
---|
36 | args = [sys.executable, './run.py'] |
---|
37 | |
---|
38 | if len(sys.argv) > 1: |
---|
39 | map_path = sys.argv[1] |
---|
40 | |
---|
41 | args.append(os.path.join('..', parpg_dir, map_path)) |
---|
42 | print args |
---|
43 | |
---|
44 | fife_editor_path = os.path.join(parpg_path, '..', 'editor') |
---|
45 | os.chdir(fife_editor_path) |
---|
46 | env = os.environ.copy() |
---|
47 | env['PYTHONPATH'] = ":".join([ |
---|
48 | os.path.join('..', parpg_path, 'editor'), |
---|
49 | os.path.join('..', parpg_path, 'local_loaders') |
---|
50 | ]) |
---|
51 | |
---|
52 | os.execve(args[0], args, env) |
---|