def get_active(sort=True): """Return a list of platforms with games (strings).""" active_platforms = [] stubs = set() all_games = pga.get_games(filter_installed=True, select='id') for game in all_games: # load game info game = Game(id=game.get('id')) platform = game.get_platform(string=False) if not platform: continue # convert to tuple if string if isinstance(platform, str): platform = (platform, ) stub = ' / '.join(platform[:-1]) prefix = '' for p in platform: p = prefix + p prefix = p + ' / ' if p not in active_platforms: active_platforms.append(p) if stub in stubs and stub not in active_platforms: active_platforms.append(stub) stubs.add(stub) return sorted(active_platforms) if sort else active_platforms
def add_game(self, game): pixbuf = get_pixbuf_for_game(game['slug'], self.icon_type, game['installed']) name = game['name'].replace('&', "&") runner = None platform = '' platform_name = '' runner_name = game['runner'] runner_human_name = '' if runner_name: game_inst = Game(game['id']) if not game_inst.is_installed: return if runner_name in self.runner_names: runner_human_name = self.runner_names[runner_name] else: runner = runners.import_runner(runner_name) runner_human_name = runner.human_name self.runner_names[runner_name] = runner_human_name platform = game_inst.get_platform() if platform: platform_name = platform.replace(' / ', ' ') lastplayed = '' if game['lastplayed']: lastplayed = time.strftime("%c", time.localtime(game['lastplayed'])) self.store.append( (game['id'], game['slug'], name, pixbuf, str(game['year'] or ''), runner_name, runner_human_name, platform, platform_name, lastplayed, game['installed']))