Skip to content

Commit

Permalink
[cli/utils] Add Cyberpunk 2077 language pack hack
Browse files Browse the repository at this point in the history
  • Loading branch information
derrod committed Dec 8, 2020
1 parent 1640a47 commit 80153d0
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
11 changes: 11 additions & 0 deletions legendary/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from legendary.utils.cli import get_boolean_choice
from legendary.utils.custom_parser import AliasedSubParsersAction
from legendary.utils.lfs import validate_files
from legendary.utils.game_workarounds import cyber_prompt_2077

# todo custom formatter for cli logger (clean info, highlighted error/warning)
logging.basicConfig(
Expand Down Expand Up @@ -577,6 +578,16 @@ def install_game(self, args):
else:
logger.info(f'Using existing repair file: {repair_file}')

# Workaround for Cyberpunk 2077 preload
if game.app_name.startswith('Ginger'):
if not self.core.is_installed(game.app_name):
args.install_tag = cyber_prompt_2077()
if game.app_name not in self.core.lgd.config:
self.core.lgd.config[game.app_name] = dict()
self.core.lgd.config.set(game.app_name, 'install_tags', ','.join(args.install_tag))
else:
args.install_tag = self.core.lgd.config.get(game.app_name, 'install_tags', fallback='').split(',')

logger.info('Preparing download...')
# todo use status queue to print progress from CLI
# This has become a little ridiculous hasn't it?
Expand Down
36 changes: 36 additions & 0 deletions legendary/utils/game_workarounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,39 @@

def is_opt_enabled(app_name):
return app_name.lower() in _optimize_default


_cyberpunk_sdl = {
'de': {'tags': ['voice_de_de'], 'name': 'Deutsch'},
'es': {'tags': ['voice_es_es'], 'name': 'español (España)'},
'fr': {'tags': ['voice_fr_fr'], 'name': 'français'},
'it': {'tags': ['voice_it_it'], 'name': 'italiano'},
'ja': {'tags': ['voice_ja_jp'], 'name': '日本語'},
'ko': {'tags': ['voice_ko_kr'], 'name': '한국어'},
'pl': {'tags': ['voice_pl_pl'], 'name': 'polski'},
'pt': {'tags': ['voice_pt_br'], 'name': 'português brasileiro'},
'ru': {'tags': ['voice_ru_ru'], 'name': 'русский'},
'zh': {'tags': ['voice_zh_cn'], 'name': '中文(中国)'}
}


def cyber_prompt_2077():
print('You are about to install Cyberpunk 2077, this game supports selective downloads for langauge packs.')
print('The following language packs are available:')
for tag, info in _cyberpunk_sdl.items():
print(' *', tag, '-', info['name'])

print('Please enter a comma-separated list of language packs to install (leave blank for english only)')
choices = input('Additional languages [e.g. de,fr]: ')
if not choices:
return ['']

tags = ['']
for c in choices.split(','):
c = c.strip()
if c in _cyberpunk_sdl:
tags.extend(_cyberpunk_sdl[c]['tags'])
else:
print('Invalid tag:', c)

return tags

0 comments on commit 80153d0

Please sign in to comment.