1
0
Fork 0
mirror of https://github.com/shlomif/PySolFC.git synced 2025-04-05 00:02:29 -04:00

* accelerated game registration

git-svn-id: file:///home/shlomif/Backup/svn-dumps/PySolFC/svnsync-repos/pysolfc/PySolFC/trunk@90 efabe8c0-fbe8-4139-b769-b5e6d273206e
This commit is contained in:
skomoroh 2006-11-08 23:28:56 +00:00
parent c687cdc9b6
commit 1b1a5e31e2
5 changed files with 32 additions and 11 deletions

View file

@ -1,6 +1,7 @@
# Makefile for PySolFC # Makefile for PySolFC
override LANG=C override LANG=C
override PYSOL_DEBUG=1
PYSOLLIB_FILES=pysollib/tk/*.py pysollib/*.py \ PYSOLLIB_FILES=pysollib/tk/*.py pysollib/*.py \
pysollib/games/*.py pysollib/games/special/*.py \ pysollib/games/*.py pysollib/games/special/*.py \

View file

@ -40,6 +40,7 @@ import sys, imp, os, types
# PySol imports # PySol imports
from mfxutil import Struct, latin1_to_ascii from mfxutil import Struct, latin1_to_ascii
from resource import CSI from resource import CSI
from settings import CHECK_GAMES
gettext = _ gettext = _
n_ = lambda x: x n_ = lambda x: x
@ -486,11 +487,8 @@ class GameManager:
def get(self, key): def get(self, key):
return self.__all_games.get(key) return self.__all_games.get(key)
def register(self, gi): def _check_game(self, gi):
##print gi.id, gi.short_name ##print 'check game:', gi.id, gi.short_name.encode('utf-8')
if not isinstance(gi, GameInfo):
raise GameInfoException, "wrong GameInfo class"
gi.plugin = self.loading_plugin
if self.__all_games.has_key(gi.id): if self.__all_games.has_key(gi.id):
raise GameInfoException, "duplicate game ID %s: %s and %s" % \ raise GameInfoException, "duplicate game ID %s: %s and %s" % \
(gi.id, str(gi.gameclass), (gi.id, str(gi.gameclass),
@ -508,6 +506,14 @@ class GameManager:
if self.__all_gamenames.has_key(n): if self.__all_gamenames.has_key(n):
raise GameInfoException, "duplicate game altname %s: %s" % \ raise GameInfoException, "duplicate game altname %s: %s" % \
(gi.id, n) (gi.id, n)
def register(self, gi):
##print gi.id, gi.short_name.encode('utf-8')
if not isinstance(gi, GameInfo):
raise GameInfoException, "wrong GameInfo class"
gi.plugin = self.loading_plugin
if self.loading_plugin or CHECK_GAMES:
self._check_game(gi)
##if 0 and gi.si.game_flags & GI.GT_XORIGINAL: ##if 0 and gi.si.game_flags & GI.GT_XORIGINAL:
## return ## return
##print gi.id, gi.name ##print gi.id, gi.name

View file

@ -51,6 +51,15 @@ def init():
##if locale_dir: locale_dir = os.path.normpath(locale_dir) ##if locale_dir: locale_dir = os.path.normpath(locale_dir)
gettext.install('pysol', locale_dir, unicode=True) gettext.install('pysol', locale_dir, unicode=True)
if os.environ.has_key('PYSOL_CHECK_GAMES') or \
os.environ.has_key('PYSOL_DEBUG'):
settings.CHECK_GAMES = True
if os.environ.has_key('PYSOL_DEBUG'):
try:
settings.DEBUG = int(os.environ['PYSOL_DEBUG'])
except:
settings.DEBUG = 1
## init toolkit ## init toolkit
if '--gtk' in sys.argv: if '--gtk' in sys.argv:
settings.TOOLKIT = 'gtk' settings.TOOLKIT = 'gtk'

View file

@ -43,6 +43,7 @@ import gettext
# PySol imports # PySol imports
from mfxutil import destruct, EnvError from mfxutil import destruct, EnvError
from util import CARDSET, DataLoader from util import CARDSET, DataLoader
import settings
from settings import PACKAGE, TOOLKIT, VERSION, SOUND_MOD from settings import PACKAGE, TOOLKIT, VERSION, SOUND_MOD
from resource import Tile from resource import Tile
from gamedb import GI from gamedb import GI
@ -110,7 +111,7 @@ def parse_option(argv):
"noplugins": False, "noplugins": False,
"nosound": False, "nosound": False,
"sound-mod": None, "sound-mod": None,
"debug": 0, "debug": None,
} }
for i in optlist: for i in optlist:
if i[0] in ("-h", "--help"): if i[0] in ("-h", "--help"):
@ -137,7 +138,10 @@ def parse_option(argv):
assert i[1] in ('pss', 'pygame', 'oss', 'win') assert i[1] in ('pss', 'pygame', 'oss', 'win')
opts["sound-mod"] = i[1] opts["sound-mod"] = i[1]
elif i[0] in ("-D", "--debug"): elif i[0] in ("-D", "--debug"):
opts["debug"] = i[1] try:
opts["debug"] = int(i[1])
except:
print >> sys.stderr, 'WARNING: invalid argument for debug'
if opts["help"]: if opts["help"]:
print _("""Usage: %s [OPTIONS] [FILE] print _("""Usage: %s [OPTIONS] [FILE]
@ -202,10 +206,9 @@ def pysol_init(app, args):
app.commandline.gameid = int(opts['gameid']) app.commandline.gameid = int(opts['gameid'])
except: except:
print >> sys.stderr, 'WARNING: invalid game id:', opts['gameid'] print >> sys.stderr, 'WARNING: invalid game id:', opts['gameid']
try: if not opts['debug'] is None:
app.debug = int(opts['debug']) settings.DEBUG = opts['debug']
except: app.debug = settings.DEBUG
print >> sys.stderr, 'invalid argument for debug'
# init games database # init games database
import games import games

View file

@ -57,3 +57,5 @@ if os.name == 'mac':
TOP_SIZE = 10 TOP_SIZE = 10
TOP_TITLE = n_('Top 10') TOP_TITLE = n_('Top 10')
DEBUG = 0 # must be integer
CHECK_GAMES = False