67.1.1
by facundo at com
Reorder back :( |
1 |
#!/usr/bin/env python
|
2 |
||
3 |
# This code is part of the 'enjuewemela' game
|
|
4 |
# License: GPLv3
|
|
5 |
# Main author: Facundo Batista
|
|
6 |
# Code, bug tracker, etc:
|
|
7 |
# https://launchpad.net/enjuewemela/
|
|
8 |
#
|
|
9 |
"""Main program for the game."""
|
|
10 |
||
72.1.2
by facundo at com
pep8 ftw |
11 |
import os |
12 |
import sys |
|
67.1.1
by facundo at com
Reorder back :( |
13 |
|
14 |
BASEDIR = os.path.dirname(os.path.realpath(__file__)) |
|
15 |
sys.path.insert(0, os.path.join(BASEDIR, "cocos")) |
|
16 |
||
17 |
import config |
|
18 |
config.BASEDIR = BASEDIR |
|
19 |
||
20 |
from cocos.director import director |
|
74.1.3
by facundo at com
All changes for new model. |
21 |
director.init(width=800, height=600, resizable=True, audio_backend='sdl') |
67.1.1
by facundo at com
Reorder back :( |
22 |
|
23 |
import cocos |
|
24 |
from cocos import scene |
|
25 |
import pyglet |
|
26 |
||
27 |
pyglet.resource.path.append(os.path.join(BASEDIR, "jewels")) |
|
28 |
pyglet.resource.path.append(os.path.join(BASEDIR, "images")) |
|
29 |
pyglet.resource.reindex() |
|
30 |
||
31 |
import games |
|
32 |
||
33 |
# i18n and l15n support!
|
|
34 |
import locale |
|
35 |
import gettext |
|
36 |
import os |
|
37 |
||
72.1.2
by facundo at com
pep8 ftw |
38 |
|
67.1.1
by facundo at com
Reorder back :( |
39 |
def get_language(): |
40 |
"""Return the language to be used by the system.
|
|
41 |
||
42 |
If it finds the system language in the translated files, it
|
|
43 |
returns it, otherwise it just returns None.
|
|
44 |
"""
|
|
45 |
loc = locale.setlocale(locale.LC_ALL, "") |
|
46 |
loc = loc[:2] |
|
47 |
traducidos = os.listdir(locale_dir) |
|
48 |
if loc in traducidos: |
|
49 |
return loc |
|
50 |
return
|
|
51 |
||
52 |
locale_dir = os.path.join(BASEDIR, "locale") |
|
53 |
gettext.install('core', locale_dir, unicode=True) |
|
54 |
idioma = get_language() |
|
55 |
if idioma is not None: |
|
56 |
mo = os.path.join(locale_dir, '%s/LC_MESSAGES/core.mo' % idioma) |
|
57 |
if not os.access(mo, os.F_OK): |
|
58 |
raise IOError("The l10n directory (for language %r) exists but " |
|
59 |
"not the core.mo file" % idioma) |
|
60 |
trans = gettext.translation('core', locale_dir, languages=[idioma]) |
|
61 |
trans.install(unicode=True) |
|
62 |
||
63 |
||
64 |
try: |
|
65 |
# pylint: disable-msg=W0612
|
|
66 |
from pyglet.media import avbin |
|
67 |
except ImportError: |
|
68 |
print _("Please get avbin from http://code.google.com/p/avbin/") |
|
69 |
exit() |
|
70 |
print _("Using AVBin module:"), avbin |
|
71 |
||
72 |
||
72.1.7
by facundo at com
Fixed explosive creation using double hint. |
73 |
def start(): |
67.1.1
by facundo at com
Reorder back :( |
74 |
if len(sys.argv) == 3: |
75 |
dmenu = sys.argv[1] |
|
76 |
spec = sys.argv[2] |
|
77 |
elif len(sys.argv) == 2: |
|
78 |
dmenu = sys.argv[1] |
|
79 |
spec = None |
|
80 |
else: |
|
81 |
dmenu = "" |
|
82 |
spec = None |
|
83 |
||
72.1.7
by facundo at com
Fixed explosive creation using double hint. |
84 |
gm = games.GameManager() |
85 |
sc = gm.start(dmenu, spec) |
|
86 |
director.run(sc) |