| Trees | Indices | Help |
|
|---|
|
|
1 #!/usr/bin/python
2 # -*- coding: iso-8859-1 -*-
3 #####################################################################
4 # Frets on Fire #
5 # Copyright (C) 2006 Sami Kyöstilä #
6 # #
7 # This program is free software; you can redistribute it and/or #
8 # modify it under the terms of the GNU General Public License #
9 # as published by the Free Software Foundation; either version 2 #
10 # of the License, or (at your option) any later version. #
11 # #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
16 # #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program; if not, write to the Free Software #
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, #
20 # MA 02110-1301, USA. #
21 #####################################################################
22
23 """
24 Main game executable.
25 """
26
27 # Register the latin-1 encoding
28 import codecs
29 import encodings.iso8859_1
30 import encodings.utf_8
31 codecs.register(lambda encoding: encodings.iso8859_1.getregentry())
32 codecs.register(lambda encoding: encodings.utf_8.getregentry())
33 assert codecs.lookup("iso-8859-1")
34 assert codecs.lookup("utf-8")
35
36 from GameEngine import GameEngine
37 from MainMenu import MainMenu
38 import Log
39 import Config
40 import Version
41
42 import getopt
43 import sys
44 import os
45
46 usage = """%(prog)s [options]
47 Options:
48 --verbose, -v Verbose messages
49 --play, -p [songName] Start playing the given song
50 """ % {"prog": sys.argv[0] }
51
52 if __name__ == "__main__":
53 try:
54 opts, args = getopt.getopt(sys.argv[1:], "vp:", ["verbose", "play="])
55 except getopt.GetoptError:
56 print usage
57 sys.exit(1)
58
59 songName = None
60 for opt, arg in opts:
61 if opt in ["--verbose", "-v"]:
62 Log.quiet = False
63 elif opt in ["--play", "-p"]:
64 songName = arg
65
66 while True:
67 config = Config.load(Version.appName() + ".ini", setAsDefault = True)
68 engine = GameEngine(config)
69 menu = MainMenu(engine, songName = songName)
70 engine.setStartupLayer(menu)
71
72 try:
73 import psyco
74 psyco.profile()
75 except:
76 Log.warn("Unable to enable psyco.")
77
78 try:
79 while engine.run():
80 pass
81 except KeyboardInterrupt:
82 pass
83
84 if engine.restartRequested:
85 Log.notice("Restarting.")
86
87 try:
88 # Determine whether were running from an exe or not
89 if hasattr(sys, "frozen"):
90 if os.name == "nt":
91 os.execl("FretsOnFire.exe", "FretsOnFire.exe", *sys.argv[1:])
92 else:
93 os.execl("./FretsOnFire", "./FretsOnFire", *sys.argv[1:])
94 else:
95 if os.name == "nt":
96 bin = "c:/python24/python"
97 else:
98 bin = "/usr/bin/python"
99 os.execl(bin, bin, "FretsOnFire.py", *sys.argv[1:])
100 except:
101 Log.warn("Restart failed.")
102 raise
103 break
104 else:
105 break
106 engine.quit()
107
| Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0beta1 on Sat Oct 20 15:25:13 2007 | http://epydoc.sourceforge.net |