Skip to content

Commit

Permalink
Lutris: Fix some games not being found (#141)
Browse files Browse the repository at this point in the history
* Lutris: Fix some games not being found

* Lutris: Match on installer_slug and then on game slug

* Lutris: Improve yml matching
  • Loading branch information
sonic2kk authored Nov 21, 2022
1 parent 5fb4091 commit a0faafe
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
14 changes: 13 additions & 1 deletion pupgui2/datastructures.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,19 @@ def get_game_config(self):
lutris_config_dir = self.install_loc.get('config_dir')
if not lutris_config_dir:
return {}
fn = str(self.installer_slug) + '-' + str(self.installed_at) + '.yml'

# search a *.yml game configuration file that contains either the install_slug+installed_at or, if not found, the game slug
fn = ''
for game_cfg_file in os.listdir(os.path.join(os.path.expanduser(lutris_config_dir), 'games')):
if str(self.installer_slug) in game_cfg_file and str(self.installed_at) in game_cfg_file:
fn = game_cfg_file
break
else:
for game_cfg_file in os.listdir(os.path.join(os.path.expanduser(lutris_config_dir), 'games')):
if self.slug in game_cfg_file:
fn = game_cfg_file
break

lutris_game_cfg = os.path.join(os.path.expanduser(lutris_config_dir), 'games', fn)
if not os.path.exists(lutris_game_cfg):
return {}
Expand Down
14 changes: 8 additions & 6 deletions pupgui2/pupgui2ctinfodialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,15 @@ def update_game_list_steam(self):

def update_game_list_lutris(self):
self.ui.listGames.clear()

lutris_games = [game for game in get_lutris_game_list(self.install_loc) if game.runner == 'wine' and game.get_game_config().get('wine', {}).get('version') == self.ctool.displayname]

self.ui.listGames.setRowCount(len(lutris_games))
self.ui.listGames.setHorizontalHeaderLabels([self.tr('Slug'), self.tr('Name')])
for i, game in enumerate(get_lutris_game_list(self.install_loc)):
if game.runner == 'wine':
cfg = game.get_game_config()
if self.ctool.displayname == cfg.get('wine', {}).get('version'):
self.ui.listGames.setItem(i, 0, QTableWidgetItem(game.slug))
self.ui.listGames.setItem(i, 1, QTableWidgetItem(game.name))
self.ui.txtNumGamesUsingTool.setText(str(len(lutris_games)))
for i, game in enumerate(lutris_games):
self.ui.listGames.setItem(i, 0, QTableWidgetItem(game.slug))
self.ui.listGames.setItem(i, 1, QTableWidgetItem(game.name))

def btn_close_clicked(self):
self.ui.close()
Expand Down

0 comments on commit a0faafe

Please sign in to comment.