source: trunk/game/parpg_editor.py @ 411

Revision 330, 1.9 KB checked in by Kaydeth_parpg, 10 years ago (diff)

Ticket #111. Patch by Kaydeth. The path seperator ":" is only valid on Linux. For windows you need ";". Python provides os.pathsep as an os independent way of using the path seperator. comment[s:trac, t:111] fixes[s:trac, t:111]

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
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
17import os
18import sys
19
20"""
21This program is a hack. To be able to hook into the FIFE map editor load and
22save functionality we have to change the import path. It runs the FIFE
23editor such that our custom loaders and savers are used instead of the stock
24FIFE ones. Ideally the FIFE editor could be extended to support custom loaders
25and savers so we don't have to resort to tricking the editor. :)
26"""
27
28if __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'] = os.pathsep.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)
Note: See TracBrowser for help on using the repository browser.