diff --git a/pysollib/app.py b/pysollib/app.py index c8aaa04c..c45aa5ec 100644 --- a/pysollib/app.py +++ b/pysollib/app.py @@ -812,11 +812,13 @@ class Application: def checkCompatibleCardsetType(self, gi, cs): assert gi is not None - assert cs is not None + cs_type = "None" + cs_subtype = "None" gc = gi.category gs = gi.subcategory - cs_type = cs.si.type - cs_subtype = cs.si.subtype + if cs is not None: + cs_type = cs.si.type + cs_subtype = cs.si.subtype t0, t1 = None, None if gc == GI.GC_FRENCH: t0 = "French" @@ -908,14 +910,14 @@ class Application: # ask return None, 0, t - def requestCompatibleCardsetType(self, id): + def requestCompatibleCardsetType(self, id, progress=None): gi = self.getGameInfo(id) # cs, cs_update_flag, t = self.getCompatibleCardset(gi, self.cardset) if cs is self.cardset: return 0 if cs is not None: - self.loadCardset(cs, update=1) + self.loadCardset(cs, update=1, progress=progress) return 1 self.requestCompatibleCardsetTypeDialog(self.cardset, gi, t) @@ -923,7 +925,7 @@ class Application: cs = self.__selectCardsetDialog(t) if cs is None: return -1 - self.loadCardset(cs, id=id) + self.loadCardset(cs, id=id, progress=progress) return 1 def requestCompatibleCardsetTypeDialog(self, cardset, gi, t): diff --git a/pysollib/main.py b/pysollib/main.py index 22d9e95b..d8cec27f 100644 --- a/pysollib/main.py +++ b/pysollib/main.py @@ -108,7 +108,7 @@ def parse_option(argv): for i in optlist: if i[0] in ("-h", "--help"): opts["help"] = True - elif i[0] in ("--deal"): + elif i[0] == "--deal": opts["deal"] = i[1] elif i[0] in ("-g", "--game"): opts["game"] = i[1] @@ -127,11 +127,12 @@ def parse_option(argv): if opts["help"]: print(_("""Usage: %s [OPTIONS] [FILE] -g --game=GAMENAME start game GAMENAME - -i --gameid=GAMEID - --french-only - --sound-mod=MOD + -i --gameid=GAMEID start game with ID GAMEID + --deal=DEAL start game deal by number DEAL + --french-only disable non-french games + --sound-mod=MOD use a certain sound module --nosound disable sound support - --noplugins disable load plugins + --noplugins disable loading plugins -h --help display this help and exit FILE - file name of a saved game @@ -403,19 +404,38 @@ Cardsets package is up to date. app.loadImages3() app.loadImages4() - # load cardset - progress = app.intro.progress - if not app.loadCardset(cardset, progress=progress, id=app.opt.last_gameid): - if not cardset: - for cardset in app.cardset_manager.getAll(): - progress.reset() + startgameid = app.opt.last_gameid - if app.loadCardset(cardset, progress=progress, - id=app.opt.last_gameid): - break - else: - fatal_no_cardsets(app) - return 3 + if app.commandline.loadgame: + pass + elif app.commandline.game is not None: + gameid = app.gdb.getGameByName(app.commandline.game) + if gameid is None: + print_err(_("can't find game: %(game)s") % { + 'game': app.commandline.game}) + sys.exit(-1) + else: + startgameid = gameid + elif app.commandline.gameid is not None: + startgameid = app.commandline.gameid + + progress = app.intro.progress + # load cardset + if startgameid != app.opt.last_gameid: + success = app.requestCompatibleCardsetType(startgameid, + progress=progress) + else: + success = app.loadCardset(cardset, progress=progress, id=startgameid) + if not success and not cardset: + for cardset in app.cardset_manager.getAll(): + progress.reset() + + if app.loadCardset(cardset, progress=progress, + id=startgameid): + break + else: + fatal_no_cardsets(app) + return 3 # ok return 0