def __init__(self, manager, key): SelectDialogTreeData.__init__(self) self.all_objects = manager.getAllSortedByName() self.all_objects = [obj for obj in self.all_objects if not obj.error] self.all_objects = [ tile for tile in self.all_objects if tile.index > 0 and tile.filename ] self.no_contents = [ SelectTileLeaf(None, None, _("(no tiles)"), key=None), ] e1 = isinstance(key, str) or len(self.all_objects) <= 17 e2 = 1 self.rootnodes = ( SelectTileNode( None, _("Solid Colors"), ( SelectTileLeaf(None, None, _("Blue"), key="#0082df"), SelectTileLeaf(None, None, _("Green"), key="#008200"), SelectTileLeaf(None, None, _("Navy"), key="#000086"), SelectTileLeaf(None, None, _("Olive"), key="#868200"), SelectTileLeaf(None, None, _("Orange"), key="#f79600"), SelectTileLeaf(None, None, _("Teal"), key="#008286"), ), expanded=e1), SelectTileNode(None, _("All Backgrounds"), lambda tile: 1, expanded=e2), )
def __init__(self, manager, key): SelectDialogTreeData.__init__(self) self.all_objects = manager.getAllSortedByName() self.no_contents = [ SelectCardsetLeaf(None, None, _("(no cardsets)"), key=None), ] # items = CSI.TYPE.items() items.sort(lambda a, b: cmp(a[1], b[1])) nodes = [] for key, name in items: if manager.registered_types.get(key): nodes.append(SelectCardsetNode(None, name, lambda cs, key=key: key == cs.si.type)) select_by_type = SelectCardsetNode(None, _("by Type"), tuple(nodes), expanded=1) # self.rootnodes = filter(None, ( select_by_type, ))
def __init__(self, manager, key): SelectDialogTreeData.__init__(self) self.all_objects = manager.getAllSortedByName() self.all_objects = [obj for obj in self.all_objects if not obj.error] self.all_objects = [tile for tile in self.all_objects if tile.index > 0 and tile.filename] self.no_contents = [ SelectTileLeaf(None, None, _("(no tiles)"), key=None), ] e1 = isinstance(key, str) or len(self.all_objects) <=17 e2 = 1 self.rootnodes = ( SelectTileNode(None, _("Solid Colors"), ( SelectTileLeaf(None, None, _("Blue"), key="#0082df"), SelectTileLeaf(None, None, _("Green"), key="#008200"), SelectTileLeaf(None, None, _("Navy"), key="#000086"), SelectTileLeaf(None, None, _("Olive"), key="#868200"), SelectTileLeaf(None, None, _("Orange"), key="#f79600"), SelectTileLeaf(None, None, _("Teal"), key="#008286"), ), expanded=e1), SelectTileNode(None, _("All Backgrounds"), lambda tile: 1, expanded=e2), )
def __init__(self, manager, key): SelectDialogTreeData.__init__(self) self.all_objects = manager.getAllSortedByName() self.no_contents = [ SelectCardsetLeaf(None, None, _("(no cardsets)"), key=None), ] # items = CSI.TYPE.items() items.sort(key=lambda x: x[1]) nodes = [] for key, name in items: if manager.registered_types.get(key): nodes.append( SelectCardsetNode(None, name, lambda cs, key=key: key == cs.si.type)) select_by_type = SelectCardsetNode(None, _("by Type"), tuple(nodes), expanded=1) # self.rootnodes = filter(None, (select_by_type, ))
def __init__(self, app): SelectDialogTreeData.__init__(self) self.all_games_gi = map(app.gdb.get, app.gdb.getGamesIdSortedByName()) self.no_games = [ SelectGameLeaf(None, None, _("(no games)"), None), ] # s_by_type = s_oriental = s_special = s_original = s_contrib = s_mahjongg = None g = [] for data in ( GI.SELECT_GAME_BY_TYPE, GI.SELECT_ORIENTAL_GAME_BY_TYPE, GI.SELECT_SPECIAL_GAME_BY_TYPE, GI.SELECT_ORIGINAL_GAME_BY_TYPE, GI.SELECT_CONTRIB_GAME_BY_TYPE, ): gg = [] for name, select_func in data: if name is None or not filter(select_func, self.all_games_gi): continue gg.append(SelectGameNode(None, _(name), select_func)) g.append(gg) select_mahjongg_game = lambda gi: gi.si.game_type == GI.GT_MAHJONGG gg = None if filter(select_mahjongg_game, self.all_games_gi): gg = SelectGameNode(None, _("Mahjongg Games"), select_mahjongg_game) g.append(gg) if g[0]: s_by_type = SelectGameNode(None, _("French games"), tuple(g[0]), expanded=1) if g[1]: s_oriental = SelectGameNode(None, _("Oriental Games"), tuple(g[1])) if g[2]: s_special = SelectGameNode(None, _("Special Games"), tuple(g[2])) if g[3]: s_original = SelectGameNode(None, _("Original Games"), tuple(g[3])) ## if g[4]: ## s_contrib = SelectGameNode(None, "Contributed Games", tuple(g[4])) if g[5]: s_mahjongg = g[5] # s_by_compatibility, gg = None, [] for name, games in GI.GAMES_BY_COMPATIBILITY: select_func = lambda gi, games=games: gi.id in games if name is None or not filter(select_func, self.all_games_gi): continue gg.append(SelectGameNode(None, name, select_func)) if 1 and gg: s_by_compatibility = SelectGameNode(None, _("by Compatibility"), tuple(gg)) pass # s_by_pysol_version, gg = None, [] for name, games in GI.GAMES_BY_PYSOL_VERSION: select_func = lambda gi, games=games: gi.id in games if name is None or not filter(select_func, self.all_games_gi): continue name = _("New games in v. ") + name gg.append(SelectGameNode(None, name, select_func)) if 1 and gg: s_by_pysol_version = SelectGameNode(None, _("by PySol version"), tuple(gg)) s_by_inventors, gg = None, [] for name, games in GI.GAMES_BY_INVENTORS: select_func = lambda gi, games=games: gi.id in games if name is None or not filter(select_func, self.all_games_gi): continue gg.append(SelectGameNode(None, name, select_func)) if 1 and gg: s_by_inventors = SelectGameNode(None, _("by Inventors"), tuple(gg)) # ul_alternate_names = UserList( list(app.gdb.getGamesTuplesSortedByAlternateName())) # self.rootnodes = filter(None, ( SelectGameNode(None, _("All Games"), None), SelectGameNode(None, _("Alternate Names"), ul_alternate_names), SelectGameNode(None, _("Popular Games"), lambda gi: gi.si.game_flags & GI.GT_POPULAR), s_mahjongg, s_oriental, s_special, SelectGameNode(None, _("Custom Games"), lambda gi: gi.si.game_type == GI.GT_CUSTOM), s_by_type, SelectGameNode(None, _('by Skill Level'), ( SelectGameNode(None, _('Luck only'), lambda gi: gi.skill_level == GI.SL_LUCK), SelectGameNode(None, _('Mostly luck'), lambda gi: gi.skill_level == GI.SL_MOSTLY_LUCK), SelectGameNode(None, _('Balanced'), lambda gi: gi.skill_level == GI.SL_BALANCED), SelectGameNode( None, _('Mostly skill'), lambda gi: gi.skill_level == GI.SL_MOSTLY_SKILL), SelectGameNode(None, _('Skill only'), lambda gi: gi.skill_level == GI.SL_SKILL), )), SelectGameNode(None, _("by Game Feature"), ( SelectGameNode(None, _("by Number of Cards"), ( SelectGameNode(None, _("32 cards"), lambda gi: gi.si.ncards == 32), SelectGameNode(None, _("48 cards"), lambda gi: gi.si.ncards == 48), SelectGameNode(None, _("52 cards"), lambda gi: gi.si.ncards == 52), SelectGameNode(None, _("64 cards"), lambda gi: gi.si.ncards == 64), SelectGameNode(None, _("78 cards"), lambda gi: gi.si.ncards == 78), SelectGameNode(None, _("104 cards"), lambda gi: gi.si.ncards == 104), SelectGameNode(None, _("144 cards"), lambda gi: gi.si.ncards == 144), SelectGameNode( None, _("Other number"), lambda gi: gi.si.ncards not in (32, 48, 52, 64, 78, 104, 144)), )), SelectGameNode(None, _("by Number of Decks"), ( SelectGameNode(None, _("1 deck games"), lambda gi: gi.si.decks == 1), SelectGameNode(None, _("2 deck games"), lambda gi: gi.si.decks == 2), SelectGameNode(None, _("3 deck games"), lambda gi: gi.si.decks == 3), SelectGameNode(None, _("4 deck games"), lambda gi: gi.si.decks == 4), )), SelectGameNode(None, _("by Number of Redeals"), ( SelectGameNode(None, _("No redeal"), lambda gi: gi.si.redeals == 0), SelectGameNode(None, _("1 redeal"), lambda gi: gi.si.redeals == 1), SelectGameNode(None, _("2 redeals"), lambda gi: gi.si.redeals == 2), SelectGameNode(None, _("3 redeals"), lambda gi: gi.si.redeals == 3), SelectGameNode(None, _("Unlimited redeals"), lambda gi: gi.si.redeals == -1), SelectGameNode(None, "Variable redeals", lambda gi: gi.si.redeals == -2), SelectGameNode( None, _("Other number of redeals"), lambda gi: gi.si.redeals not in (-1, 0, 1, 2, 3)), )), s_by_compatibility, )), s_by_pysol_version, s_by_inventors, SelectGameNode(None, _("Other Categories"), ( SelectGameNode(None, _("Games for Children (very easy)"), lambda gi: gi.si.game_flags & GI.GT_CHILDREN), SelectGameNode(None, _("Games with Scoring"), lambda gi: gi.si.game_flags & GI.GT_SCORE), SelectGameNode( None, _("Games with Separate Decks"), lambda gi: gi.si.game_flags & GI.GT_SEPARATE_DECKS), SelectGameNode(None, _("Open Games (all cards visible)"), lambda gi: gi.si.game_flags & GI.GT_OPEN), SelectGameNode(None, _("Relaxed Variants"), lambda gi: gi.si.game_flags & GI.GT_RELAXED), )), s_original, s_contrib, ))
def __init__(self, manager, key): SelectDialogTreeData.__init__(self) self.all_objects = manager.getAllSortedByName() self.all_objects = [obj for obj in self.all_objects if not obj.error] self.no_contents = [ SelectCardsetLeaf(None, None, _("(no cardsets)"), key=None), ] # select_by_type = None items = CSI.TYPE.items() items.sort(lambda a, b: cmp(a[1], b[1])) nodes = [] for key, name in items: if manager.registered_types.get(key): nodes.append(SelectCardsetNode(None, name, lambda cs, key=key: key == cs.si.type)) if nodes: select_by_type = SelectCardsetNode(None, _("by Type"), tuple(nodes), expanded=1) # select_by_style = None items = CSI.STYLE.items() items.sort(lambda a, b: cmp(a[1], b[1])) nodes = [] for key, name in items: if manager.registered_styles.get(key): nodes.append(SelectCardsetNode(None, name, lambda cs, key=key: key in cs.si.styles)) if nodes: nodes.append(SelectCardsetNode(None, _("Uncategorized"), lambda cs: not cs.si.styles)) select_by_style = SelectCardsetNode(None, _("by Style"), tuple(nodes)) # select_by_nationality = None items = CSI.NATIONALITY.items() items.sort(lambda a, b: cmp(a[1], b[1])) nodes = [] for key, name in items: if manager.registered_nationalities.get(key): nodes.append(SelectCardsetNode(None, name, lambda cs, key=key: key in cs.si.nationalities)) if nodes: nodes.append(SelectCardsetNode(None, _("Uncategorized"), lambda cs: not cs.si.nationalities)) select_by_nationality = SelectCardsetNode(None, _("by Nationality"), tuple(nodes)) # select_by_date = None items = CSI.DATE.items() items.sort(lambda a, b: cmp(a[1], b[1])) nodes = [] for key, name in items: if manager.registered_dates.get(key): nodes.append(SelectCardsetNode(None, name, lambda cs, key=key: key in cs.si.dates)) if nodes: nodes.append(SelectCardsetNode(None, _("Uncategorized"), lambda cs: not cs.si.dates)) select_by_date = SelectCardsetNode(None, _("by Date"), tuple(nodes)) # self.rootnodes = filter(None, ( SelectCardsetNode(None, _("All Cardsets"), lambda cs: 1, expanded=len(self.all_objects)<=12), SelectCardsetNode(None, _("by Size"), ( SelectCardsetNode(None, _("Tiny cardsets"), lambda cs: cs.si.size == CSI.SIZE_TINY), SelectCardsetNode(None, _("Small cardsets"), lambda cs: cs.si.size == CSI.SIZE_SMALL), SelectCardsetNode(None, _("Medium cardsets"), lambda cs: cs.si.size == CSI.SIZE_MEDIUM), SelectCardsetNode(None, _("Large cardsets"), lambda cs: cs.si.size == CSI.SIZE_LARGE), SelectCardsetNode(None, _("XLarge cardsets"), lambda cs: cs.si.size == CSI.SIZE_XLARGE), ), expanded=1), select_by_type, select_by_style, select_by_date, select_by_nationality, ))
def __init__(self, app): SelectDialogTreeData.__init__(self) self.all_games_gi = map(app.gdb.get, app.gdb.getGamesIdSortedByName()) self.no_games = [SelectGameLeaf(None, None, _("(no games)"), None)] # s_by_type = s_oriental = s_special = s_original = s_contrib = s_mahjongg = None g = [] for data in ( GI.SELECT_GAME_BY_TYPE, GI.SELECT_ORIENTAL_GAME_BY_TYPE, GI.SELECT_SPECIAL_GAME_BY_TYPE, GI.SELECT_ORIGINAL_GAME_BY_TYPE, GI.SELECT_CONTRIB_GAME_BY_TYPE, ): gg = [] for name, select_func in data: if name is None or not filter(select_func, self.all_games_gi): continue gg.append(SelectGameNode(None, _(name), select_func)) g.append(gg) select_mahjongg_game = lambda gi: gi.si.game_type == GI.GT_MAHJONGG gg = None if filter(select_mahjongg_game, self.all_games_gi): gg = SelectGameNode(None, _("Mahjongg Games"), select_mahjongg_game) g.append(gg) if g[0]: s_by_type = SelectGameNode(None, _("French games"), tuple(g[0]), expanded=1) if g[1]: s_oriental = SelectGameNode(None, _("Oriental Games"), tuple(g[1])) if g[2]: s_special = SelectGameNode(None, _("Special Games"), tuple(g[2])) if g[3]: s_original = SelectGameNode(None, _("Original Games"), tuple(g[3])) ## if g[4]: ## s_contrib = SelectGameNode(None, "Contributed Games", tuple(g[4])) if g[5]: s_mahjongg = g[5] # s_by_compatibility, gg = None, [] for name, games in GI.GAMES_BY_COMPATIBILITY: select_func = lambda gi, games=games: gi.id in games if name is None or not filter(select_func, self.all_games_gi): continue gg.append(SelectGameNode(None, name, select_func)) if 1 and gg: s_by_compatibility = SelectGameNode(None, _("by Compatibility"), tuple(gg)) pass # s_by_pysol_version, gg = None, [] for name, games in GI.GAMES_BY_PYSOL_VERSION: select_func = lambda gi, games=games: gi.id in games if name is None or not filter(select_func, self.all_games_gi): continue name = _("New games in v. ") + name gg.append(SelectGameNode(None, name, select_func)) if 1 and gg: s_by_pysol_version = SelectGameNode(None, _("by PySol version"), tuple(gg)) s_by_inventors, gg = None, [] for name, games in GI.GAMES_BY_INVENTORS: select_func = lambda gi, games=games: gi.id in games if name is None or not filter(select_func, self.all_games_gi): continue gg.append(SelectGameNode(None, name, select_func)) if 1 and gg: s_by_inventors = SelectGameNode(None, _("by Inventors"), tuple(gg)) # ul_alternate_names = UserList(list(app.gdb.getGamesTuplesSortedByAlternateName())) # self.rootnodes = filter( None, ( SelectGameNode(None, _("All Games"), None), SelectGameNode(None, _("Alternate Names"), ul_alternate_names), SelectGameNode(None, _("Popular Games"), lambda gi: gi.si.game_flags & GI.GT_POPULAR), s_mahjongg, s_oriental, s_special, SelectGameNode(None, _("Custom Games"), lambda gi: gi.si.game_type == GI.GT_CUSTOM), s_by_type, SelectGameNode( None, _("by Skill Level"), ( SelectGameNode(None, _("Luck only"), lambda gi: gi.skill_level == GI.SL_LUCK), SelectGameNode(None, _("Mostly luck"), lambda gi: gi.skill_level == GI.SL_MOSTLY_LUCK), SelectGameNode(None, _("Balanced"), lambda gi: gi.skill_level == GI.SL_BALANCED), SelectGameNode(None, _("Mostly skill"), lambda gi: gi.skill_level == GI.SL_MOSTLY_SKILL), SelectGameNode(None, _("Skill only"), lambda gi: gi.skill_level == GI.SL_SKILL), ), ), SelectGameNode( None, _("by Game Feature"), ( SelectGameNode( None, _("by Number of Cards"), ( SelectGameNode(None, _("32 cards"), lambda gi: gi.si.ncards == 32), SelectGameNode(None, _("48 cards"), lambda gi: gi.si.ncards == 48), SelectGameNode(None, _("52 cards"), lambda gi: gi.si.ncards == 52), SelectGameNode(None, _("64 cards"), lambda gi: gi.si.ncards == 64), SelectGameNode(None, _("78 cards"), lambda gi: gi.si.ncards == 78), SelectGameNode(None, _("104 cards"), lambda gi: gi.si.ncards == 104), SelectGameNode(None, _("144 cards"), lambda gi: gi.si.ncards == 144), SelectGameNode( None, _("Other number"), lambda gi: gi.si.ncards not in (32, 48, 52, 64, 78, 104, 144), ), ), ), SelectGameNode( None, _("by Number of Decks"), ( SelectGameNode(None, _("1 deck games"), lambda gi: gi.si.decks == 1), SelectGameNode(None, _("2 deck games"), lambda gi: gi.si.decks == 2), SelectGameNode(None, _("3 deck games"), lambda gi: gi.si.decks == 3), SelectGameNode(None, _("4 deck games"), lambda gi: gi.si.decks == 4), ), ), SelectGameNode( None, _("by Number of Redeals"), ( SelectGameNode(None, _("No redeal"), lambda gi: gi.si.redeals == 0), SelectGameNode(None, _("1 redeal"), lambda gi: gi.si.redeals == 1), SelectGameNode(None, _("2 redeals"), lambda gi: gi.si.redeals == 2), SelectGameNode(None, _("3 redeals"), lambda gi: gi.si.redeals == 3), SelectGameNode(None, _("Unlimited redeals"), lambda gi: gi.si.redeals == -1), SelectGameNode(None, "Variable redeals", lambda gi: gi.si.redeals == -2), SelectGameNode( None, _("Other number of redeals"), lambda gi: gi.si.redeals not in (-1, 0, 1, 2, 3) ), ), ), s_by_compatibility, ), ), s_by_pysol_version, s_by_inventors, SelectGameNode( None, _("Other Categories"), ( SelectGameNode( None, _("Games for Children (very easy)"), lambda gi: gi.si.game_flags & GI.GT_CHILDREN ), SelectGameNode(None, _("Games with Scoring"), lambda gi: gi.si.game_flags & GI.GT_SCORE), SelectGameNode( None, _("Games with Separate Decks"), lambda gi: gi.si.game_flags & GI.GT_SEPARATE_DECKS ), SelectGameNode( None, _("Open Games (all cards visible)"), lambda gi: gi.si.game_flags & GI.GT_OPEN ), SelectGameNode(None, _("Relaxed Variants"), lambda gi: gi.si.game_flags & GI.GT_RELAXED), ), ), s_original, s_contrib, ), )
def __init__(self, manager, key): SelectDialogTreeData.__init__(self) self.all_objects = manager.getAllSortedByName() self.all_objects = [obj for obj in self.all_objects if not obj.error] self.no_contents = [ SelectCardsetLeaf(None, None, _("(no cardsets)"), key=None), ] # select_by_type = None items = CSI.TYPE.items() items.sort(key=lambda x: x[1]) nodes = [] for key, name in items: if manager.registered_types.get(key): nodes.append( SelectCardsetNode(None, name, lambda cs, key=key: key == cs.si.type)) if nodes: select_by_type = SelectCardsetNode(None, _("by Type"), tuple(nodes), expanded=1) # select_by_style = None items = CSI.STYLE.items() items.sort(key=lambda x: x[1]) nodes = [] for key, name in items: if manager.registered_styles.get(key): nodes.append( SelectCardsetNode(None, name, lambda cs, key=key: key in cs.si.styles)) if nodes: nodes.append( SelectCardsetNode(None, _("Uncategorized"), lambda cs: not cs.si.styles)) select_by_style = SelectCardsetNode(None, _("by Style"), tuple(nodes)) # select_by_nationality = None items = CSI.NATIONALITY.items() items.sort(key=lambda x: x[1]) nodes = [] for key, name in items: if manager.registered_nationalities.get(key): nodes.append( SelectCardsetNode( None, name, lambda cs, key=key: key in cs.si.nationalities)) if nodes: nodes.append( SelectCardsetNode(None, _("Uncategorized"), lambda cs: not cs.si.nationalities)) select_by_nationality = SelectCardsetNode(None, _("by Nationality"), tuple(nodes)) # select_by_date = None items = CSI.DATE.items() items.sort(key=lambda x: x[1]) nodes = [] for key, name in items: if manager.registered_dates.get(key): nodes.append( SelectCardsetNode(None, name, lambda cs, key=key: key in cs.si.dates)) if nodes: nodes.append( SelectCardsetNode(None, _("Uncategorized"), lambda cs: not cs.si.dates)) select_by_date = SelectCardsetNode(None, _("by Date"), tuple(nodes)) # self.rootnodes = filter(None, ( SelectCardsetNode(None, _("All Cardsets"), lambda cs: 1, expanded=len(self.all_objects) <= 12), SelectCardsetNode( None, _("by Size"), ( SelectCardsetNode(None, _("Tiny cardsets"), lambda cs: cs.si.size == CSI.SIZE_TINY), SelectCardsetNode(None, _("Small cardsets"), lambda cs: cs.si.size == CSI.SIZE_SMALL), SelectCardsetNode( None, _("Medium cardsets"), lambda cs: cs.si.size == CSI.SIZE_MEDIUM), SelectCardsetNode(None, _("Large cardsets"), lambda cs: cs.si.size == CSI.SIZE_LARGE), SelectCardsetNode( None, _("XLarge cardsets"), lambda cs: cs.si.size == CSI.SIZE_XLARGE), ), expanded=1), select_by_type, select_by_style, select_by_date, select_by_nationality, ))