File: Magicor-LevelEditor.py

package info (click to toggle)
magicor 1.1-3
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 24,272 kB
  • ctags: 672
  • sloc: python: 6,332; makefile: 75
file content (48 lines) | stat: -rw-r--r-- 1,408 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/python
#
# Magicor Level Editor
# Copyright 2006  Peter Gebauer. Licensed as Public Domain.
# (see LICENSE for more info)
from optparse import OptionParser
import sys, os
sys.path.append(".")

##-->win
def change_to_correct_path(): #taken from pygame wiki cookbook 
    import os, sys 
    exe_base_dir = os.path.abspath(os.path.dirname(sys.argv[0])) 
    os.chdir(exe_base_dir) 
    sys.path.append(exe_base_dir) 
 
if sys.platform=='win32': 
    change_to_correct_path() #usefull when running from another dir, desktop or appbar
##<--win

from magicor import getConfig
from magicor.editor.gtkgui import GtkEditor

parser = OptionParser()
##-->win
if sys.platform=='win32':
    parser.add_option("-c", "--config", dest="configPath",
                  default = ".",
                  help="use this config path, default is magicor directory.")
    baseConf=".\magicor-editor.conf"
else:
    parser.add_option("-c", "--config", dest="configPath",
                  default = "###CONFIG_PATH###",
                  help="use this default config, default ###CONFIG_PATH###")
    baseConf="~/.magicor/magicor-editor.conf"
##<--win

(options, args) = parser.parse_args()

paths = [options.configPath, baseConf] ##@@

conf = getConfig(paths)
##-->win
if sys.platform=='win32': # not clean but...
    conf["user_path"]='.'
    conf["data_path"]='data'
##<--win
GtkEditor(conf, args and args[0] or None)