forked from SuperTux/flexlay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsupertux-level
executable file
·62 lines (49 loc) · 2 KB
/
supertux-level
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env python3
# Flexlay - A Generic 2D Game Editor
# Copyright (C) 2014 Ingo Ruhnke <grumbel@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import argparse
import logging
import sys
from supertux.level import Level
from util.config import Config
def main():
has_error = False
parser = argparse.ArgumentParser(description="SuperTux Level Tool")
parser.add_argument("LEVELFILE", action="store", type=str, nargs="+",
help=".stl file to load")
parser.add_argument("-d", "--datadir", metavar="DIR", action="store", type=str,
help="SuperTux data directory directory")
parser.add_argument("-o", "--output", metavar="FILE", action="store", type=str,
help="Load and resave the level to FILE")
args = parser.parse_args()
config = Config.create("supertux-editor")
if args.datadir is not None:
config.datadir = args.datadir
elif not config.datadir:
raise RuntimeError("datadir missing, use --datadir DIR")
for levelfile in args.LEVELFILE:
logging.info("Loading {}".format(levelfile))
try:
level = Level.from_file(levelfile)
if args.output:
level.save_v2(args.output)
except Exception as e:
logging.exception("ERROR")
has_error = True
return 1 if has_error else 0
if __name__ == "__main__":
sys.exit(main())
# EOF #