class EditGameConfigDialog(Gtk.Dialog, GameDialogCommon): """ Game config edit dialog """ def __init__(self, parent, game): super(EditGameConfigDialog, self).__init__() self.parent_window = parent self.game = game self.lutris_config = LutrisConfig(game=game) self.runner_name = self.lutris_config.runner game_name = self.lutris_config.config.get("realname", game) self.set_title("Edit game configuration for %s" % game_name) self.set_size_request(500, 500) self.build_notebook() self.build_game_tab() self.build_runner_tab() self.build_system_tab() self.build_action_area(Gtk.STOCK_EDIT, self.edit_game) self.show_all() self.run() def edit_game(self, _widget=None): """Save the changes""" self.lutris_config.save(config_type="game") self.destroy()
def mark_as_installed(appid, runner_name, game_info): for key in ['name', 'slug']: assert game_info[key] logger.info("Setting %s as installed" % game_info['name']) config_id = (game_info.get('config_path') or make_game_config_id(game_info['slug'])) game_id = pga.add_or_update( name=game_info['name'], runner=runner_name, slug=game_info['slug'], installed=1, configpath=config_id, installer_slug=game_info['installer_slug'] ) config = LutrisConfig( runner_slug=runner_name, game_config_id=config_id, ) config.raw_game_config.update({ 'appid': appid, 'exe': game_info['exe'], 'args': game_info['args'] }) config.raw_system_config.update({ 'disable_runtime': True }) config.save() return game_id
def __init__(self, settings=None): """Initialize NullDC joy2key $(xwininfo -root -tree | grep nullDC | grep -v VMU |\ awk '{print $1}') \ -X -rcfile ~/.joy2keyrc \ -buttons y a b x c r l r o s -axis Left Right Up Down """ super(nulldc, self).__init__(settings) self.description = "Runs Dreamcast games with nullDC emulator" self.platform = "Sega Dreamcast" self.is_installable = False self.depends = "wine" config = LutrisConfig(runner=self.__class__.__name__) self.nulldc_path = config.get_path() self.executable = "nullDC_1.0.3_nommu.exe" self.args = "" self.game_options = [{ 'option': 'iso', 'type': 'file', 'name': 'iso', 'label': 'Disc image' }] self.runner_options = self.runner_options + [{ 'option': 'fullscreen', 'type': 'bool', 'name': 'fullscreen', 'label': 'Fullscreen' }] if settings: self.settings = settings
def install(self): success = super(hatari, self).install() if not success: return False config_path = os.path.expanduser('~/.hatari') if not os.path.exists(config_path): os.makedirs(config_path) bios_path = os.path.expanduser('~/.hatari/bios') if not os.path.exists(bios_path): os.makedirs(bios_path) dlg = QuestionDialog({ 'question': "Do you want to select an Atari ST BIOS file?", 'title': "Use BIOS file?", }) if dlg.result == dlg.YES: bios_dlg = FileDialog("Select a BIOS file") bios_filename = bios_dlg.filename if not bios_filename: return shutil.copy(bios_filename, bios_path) bios_path = os.path.join(bios_path, os.path.basename(bios_filename)) config = LutrisConfig(runner_slug='hatari') config.raw_runner_config.update({'bios_file': bios_path}) config.save() return True
def install(self): success = super(pcsxr, self).install() if not success: return False config_path = os.path.expanduser('~/.pcsxr') if not os.path.exists(config_path): os.makedirs(config_path) # Bios bios_path = os.path.expanduser('~/.pcsxr/bios') if not os.path.exists(bios_path): os.makedirs(bios_path) dlg = QuestionDialog({ 'question': ("Do you want to select a Playstation BIOS file?\n\n" "The BIOS is the core code running the machine.\n" "PCSX-Reloaded includes an emulated BIOS, but it is " "still incomplete. \n" "Using an original BIOS avoids some bugs and reduced " "compatibility \n" "with some games."), 'title': "Use BIOS file?", }) if dlg.result == dlg.YES: bios_dlg = FileDialog("Select a BIOS file") bios_src = bios_dlg.filename shutil.copy(bios_src, bios_path) # Save bios in config bios_path = os.path.join(bios_path, os.path.basename(bios_src)) runner_config = LutrisConfig(runner='pcsxr') runner_config.config_type = 'runner' runner_config.runner_config = {'pcsxr': {'bios': bios_path}} runner_config.save() return True
def create_launcher(game, desktop=False, menu=False): """ Create desktop file """ config = LutrisConfig(game=game) desktop_dir = subprocess.Popen(['xdg-user-dir', 'DESKTOP'], stdout=subprocess.PIPE).communicate()[0] desktop_dir = desktop_dir.strip() launcher_content = """[Desktop Entry] Type=Application Name=%s Icon=%s Exec=lutris lutris:%s Categories=Game """ % (config.get_name(), 'lutris_' + game, game) launcher_filename = "%s.desktop" % game tmp_launcher_path = os.path.join(CACHE_DIR, launcher_filename) tmp_launcher = open(tmp_launcher_path, "w") tmp_launcher.write(launcher_content) tmp_launcher.close() os.chmod(tmp_launcher_path, stat.S_IREAD | stat.S_IWRITE | stat.S_IEXEC | stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP) if desktop: shutil.copy(tmp_launcher_path, os.path.join(desktop_dir, launcher_filename)) if menu: menu_path = os.path.join(BaseDirectory.xdg_data_home, 'applications') shutil.copy(tmp_launcher_path, os.path.join(menu_path, launcher_filename)) os.remove(tmp_launcher_path)
def create_config(self): """Create a Lutris config for the current game""" config = LutrisConfig(runner_slug=self.runner, game_config_id=self.config_id) config.raw_game_config.update({ "appid": self.appid, "exe": self.details["exe"], "args": self.details["args"] }) config.raw_system_config.update({"disable_runtime": True}) config.save()
def install(self, installer_path=None): if installer_path: self.msi_exec(installer_path, quiet=True) Gdk.threads_enter() dlg = DirectoryDialog('Where is Steam.exe installed?') self.game_path = dlg.folder Gdk.threads_leave() config = LutrisConfig(runner='winesteam') config.runner_config = {'system': {'game_path': self.game_path}} config.save()
def __init__(self, settings=None): super(winesteam, self).__init__(settings) self.platform = "Steam (Windows)" config = LutrisConfig(runner=self.__class__.__name__) self.game_path = config.get_path() self.arguments = [] self.game_options = [ {'option': 'appid', 'type': 'string', 'label': 'appid'}, {'option': 'args', 'type': 'string', 'label': 'arguments'}, {'option': 'prefix', 'type': 'directory_chooser', 'label': 'Prefix'} ] self.settings = settings
def __init__(self, parent=None): super().__init__(_("System preferences"), parent=parent) self.game = None self.runner_name = None self.lutris_config = LutrisConfig() self.set_default_size(DIALOG_WIDTH, DIALOG_HEIGHT) self.build_notebook() self.build_tabs("system") self.build_action_area(self.on_save) self.show_all()
class RunnerConfigDialog(Gtk.Dialog): """Runners management dialog""" def __init__(self, runner): Gtk.Dialog.__init__(self) runner_name = runner.__class__.__name__ self.set_title("Configure %s" % runner_name) self.set_size_request(570, 500) self.runner = runner_name self.lutris_config = LutrisConfig(runner=runner_name) #Notebook for choosing between runner and system configuration self.notebook = Gtk.Notebook() self.vbox.pack_start(self.notebook, True, True, 0) #Runner configuration self.runner_config_vbox = RunnerBox(self.lutris_config, "runner") runner_scrollwindow = Gtk.ScrolledWindow() runner_scrollwindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) runner_scrollwindow.add_with_viewport(self.runner_config_vbox) self.notebook.append_page(runner_scrollwindow, Gtk.Label(label="Runner configuration")) #System configuration self.system_config_vbox = SystemBox(self.lutris_config, "runner") system_scrollwindow = Gtk.ScrolledWindow() system_scrollwindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) system_scrollwindow.add_with_viewport(self.system_config_vbox) self.notebook.append_page(system_scrollwindow, Gtk.Label(label="System configuration")) #Action buttons cancel_button = Gtk.Button(None, Gtk.STOCK_CANCEL) ok_button = Gtk.Button(None, Gtk.STOCK_OK) self.action_area.pack_start(cancel_button, True, True, 0) self.action_area.pack_start(ok_button, True, True, 0) cancel_button.connect("clicked", self.close) ok_button.connect("clicked", self.ok_clicked) self.show_all() self.run() def close(self, _widget): self.destroy() def ok_clicked(self, _wigdet): assert self.lutris_config.config_type == 'runner' self.lutris_config.config_type = "runner" self.lutris_config.save() self.destroy()
class RunnerConfigDialog(Gtk.Dialog): """Runners management dialog.""" def __init__(self, runner): Gtk.Dialog.__init__(self) runner_name = runner.__class__.__name__ self.set_title("Configure %s" % runner_name) self.set_size_request(570, 500) self.runner_name = runner_name self.lutris_config = LutrisConfig(runner=runner_name) # Notebook for choosing between runner and system configuration self.notebook = Gtk.Notebook() self.vbox.pack_start(self.notebook, True, True, 0) # Runner configuration self.runner_config_vbox = RunnerBox(self.lutris_config, "runner", self.runner_name) runner_scrollwindow = Gtk.ScrolledWindow() runner_scrollwindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) runner_scrollwindow.add_with_viewport(self.runner_config_vbox) self.notebook.append_page(runner_scrollwindow, Gtk.Label(label="Runner configuration")) # System configuration self.system_config_vbox = SystemBox(self.lutris_config, "runner") system_scrollwindow = Gtk.ScrolledWindow() system_scrollwindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) system_scrollwindow.add_with_viewport(self.system_config_vbox) self.notebook.append_page(system_scrollwindow, Gtk.Label(label="System configuration")) # Action buttons cancel_button = Gtk.Button("Cancel") ok_button = Gtk.Button("Ok") self.action_area.pack_start(cancel_button, True, True, 0) self.action_area.pack_start(ok_button, True, True, 0) cancel_button.connect("clicked", self.close) ok_button.connect("clicked", self.ok_clicked) self.show_all() self.run() def close(self, _widget): self.destroy() def ok_clicked(self, _wigdet): self.lutris_config.config_type = "runner" self.lutris_config.save() self.destroy()
class SystemConfigDialog(Dialog, GameDialogCommon): def __init__(self): super(SystemConfigDialog, self).__init__("System preferences") self.set_size_request(500, 500) self.lutris_config = LutrisConfig() self.system_config_vbox = SystemBox(self.lutris_config, 'system') self.vbox.pack_start(self.system_config_vbox, True, True, 0) self.build_action_area("Save", self.save_config) self.show_all() def save_config(self, widget): self.lutris_config.save() self.destroy()
def __init__(self, parent=None): super().__init__("System preferences", parent=parent) self.game = None self.runner_name = None self.lutris_config = LutrisConfig() self.set_default_size(DIALOG_WIDTH, DIALOG_HEIGHT) self.system_box = SystemBox(self.lutris_config) self.system_sw = self.build_scrolled_window(self.system_box) self.vbox.pack_start(self.system_sw, True, True, 0) self.build_action_area(self.on_save) self.show_all()
def load_config(self): """Load the game's configuration.""" self.config = LutrisConfig(game=self.slug) if not self.is_installed: return if not self.runner_name: logger.error('Incomplete data for %s', self.slug) return try: runner_class = import_runner(self.runner_name) except InvalidRunner: logger.error("Unable to import runner %s for %s", self.runner_name, self.slug) self.runner = runner_class(self.config)
def __init__(self, runner, parent=None): self.runner_name = runner.__class__.__name__ super().__init__("Configure %s" % runner.human_name, parent=parent) self.game = None self.saved = False self.lutris_config = LutrisConfig(runner_slug=self.runner_name) self.set_default_size(DIALOG_WIDTH, DIALOG_HEIGHT) self.build_notebook() self.build_tabs("runner") self.build_action_area(self.on_save) self.show_all()
def load_config(self): """Load the game's configuration.""" if not self.is_installed: return self.config = LutrisConfig( runner_slug=self.runner_name, game_config_id=self.game_config_id ) self.runner = self._get_runner() if self.discord_presence.available: self.discord_presence.client_id = self.config.system_config.get("discord_client_id") or DEFAULT_DISCORD_CLIENT_ID self.discord_presence.game_name = self.config.system_config.get("discord_custom_game_name") or self.name self.discord_presence.show_runner = self.config.system_config.get("discord_show_runner", True) self.discord_presence.runner_name = self.config.system_config.get("discord_custom_runner_name") or self.runner_name self.discord_presence.rpc_enabled = self.config.system_config.get("discord_rpc_enabled", True)
def on_runner_installed(*args): # pylint: disable=unused-argument config_path = system.create_folder("~/.atari800") bios_archive = os.path.join(config_path, "atari800-bioses.zip") dlg = DownloadDialog(self.bios_url, bios_archive) dlg.run() if not system.path_exists(bios_archive): ErrorDialog(_("Could not download Atari 800 BIOS archive")) return extract.extract_archive(bios_archive, config_path) os.remove(bios_archive) config = LutrisConfig(runner_slug="atari800") config.raw_runner_config.update({"bios_path": config_path}) config.save() if callback: callback()
def on_runner_changed(self, widget): """Action called when runner drop down is changed.""" runner_index = widget.get_active() current_page = self.notebook.get_current_page() if runner_index == 0: self.runner_name = None self.lutris_config = LutrisConfig() else: self.runner_name = widget.get_model()[runner_index][1] # XXX DANGER ZONE self.lutris_config = LutrisConfig(runner=self.runner_name) self.rebuild_tabs() self.notebook.set_current_page(current_page)
def system_config(self): """Return system config, cascaded from base, runner and game's system config. """ base_system_config = LutrisConfig().system_config # Runner level config, overrides system config runner_system_config = self.runner_config.get('system') or {} base_system_config.update(runner_system_config) # Game level config, takes precedence over everything game_system_config = self.settings.get('system') or {} base_system_config.update(game_system_config) return base_system_config
class RunnerConfigDialog(GameDialogCommon): """Runner config edit dialog.""" def __init__(self, runner, parent=None): self.runner_name = runner.__class__.__name__ super().__init__(_("Configure %s") % runner.human_name, parent=parent) self.saved = False self.lutris_config = LutrisConfig(runner_slug=self.runner_name) self.build_notebook() self.build_tabs("runner") self.build_action_area(self.on_save) self.show_all() def on_save(self, wigdet, data=None): self.lutris_config.save() self.destroy()
def on_runner_installed(*args): config_path = system.create_folder("~/.atari800") bios_archive = os.path.join(config_path, "atari800-bioses.zip") dlg = DownloadDialog(self.bios_url, bios_archive) dlg.run() if not system.path_exists(bios_archive): ErrorDialog("Could not download Atari800 BIOS archive") return extract.extract_archive(bios_archive, config_path) os.remove(bios_archive) config = LutrisConfig(runner_slug="atari800") config.raw_runner_config.update({"bios_path": config_path}) config.save() if callback: callback()
def on_runner_installed(*args): config_path = system.create_folder("~/.atari800") bios_archive = os.path.join(config_path, 'atari800-bioses.zip') dlg = DownloadDialog(self.bios_url, bios_archive) dlg.run() if not system.path_exists(bios_archive): ErrorDialog("Could not download Atari800 BIOS archive") return extract.extract_archive(bios_archive, config_path) os.remove(bios_archive) config = LutrisConfig(runner_slug='atari800') config.raw_runner_config.update({'bios_path': config_path}) config.save() if callback: callback()
def install_from_origin(self, origin_game, manifest): offer_id = manifest["id"].split("@")[0] logger.debug("Installing Origin game %s", offer_id) service_game = ServiceGameCollection.get_game("origin", offer_id) if not service_game: logger.error( "Aborting install, %s is not present in the game library.", offer_id) return lutris_game_id = slugify(service_game["name"]) + "-" + self.id existing_game = get_game_by_field(lutris_game_id, "installer_slug") if existing_game: return game_config = LutrisConfig( game_config_id=origin_game["configpath"]).game_level game_config["game"]["args"] = get_launch_arguments(manifest["id"]) configpath = write_game_config(lutris_game_id, game_config) game_id = add_game( name=service_game["name"], runner=origin_game["runner"], slug=slugify(service_game["name"]), directory=origin_game["directory"], installed=1, installer_slug=lutris_game_id, configpath=configpath, service=self.id, service_id=offer_id, ) return game_id
def on_runner_changed(self, widget): """Action called when runner drop down is changed""" selected_runner = widget.get_active() scroll_windows_children = [self.conf_scroll_window.get_children(), self.runner_scroll_window.get_children(), self.system_scroll_window.get_children()] for scroll_window_children in scroll_windows_children: for child in scroll_window_children: child.destroy() if selected_runner == 0: no_runner_label = Gtk.Label(label="Choose a runner from the list") no_runner_label.show() self.runner_scroll_window.add_with_viewport(no_runner_label) return self.runner_class = widget.get_model()[selected_runner][1] self.lutris_config = LutrisConfig(self.runner_class) self.game_config_vbox = GameConfigVBox(self.lutris_config, "game") self.conf_scroll_window.add_with_viewport(self.game_config_vbox) self.conf_scroll_window.show_all() #Load runner box self.runner_options_vbox = RunnerConfigVBox(self.lutris_config, "game") self.runner_scroll_window.add_with_viewport(self.runner_options_vbox) self.runner_scroll_window.show_all() #Load system box self.system_config_vbox = SystemConfigVBox(self.lutris_config, "game") self.system_scroll_window.add_with_viewport(self.system_config_vbox) self.system_scroll_window.show_all()
def install_from_ubisoft(self, ubisoft_connect, game): app_name = game["name"] lutris_game_id = slugify(game["name"]) + "-" + self.id existing_game = get_game_by_field(lutris_game_id, "installer_slug") if existing_game: logger.debug("Ubisoft Connect game %s is already installed", app_name) return logger.debug("Installing Ubisoft Connect game %s", app_name) game_config = LutrisConfig( game_config_id=ubisoft_connect["configpath"]).game_level game_config["game"]["args"] = f"uplay://launch/{game['appid']}" configpath = write_game_config(lutris_game_id, game_config) game_id = add_game( name=game["name"], runner=self.runner, slug=slugify(game["name"]), directory=ubisoft_connect["directory"], installed=1, installer_slug=lutris_game_id, configpath=configpath, service=self.id, service_id=game["appid"], ) return game_id
def __init__(self, parent, game=None): super(AddGameDialog, self).__init__() self.parent_window = parent self.lutris_config = LutrisConfig() self.game = game self.installed = False self.set_title("Add a new game") self.set_size_request(600, 500) if game: name = game.name self.runner_name = game.runner_name self.slug = game.slug else: name = None self.runner_name = None self.slug = None self.build_name_entry(name) self.build_runner_dropdown() self.build_notebook() self.build_game_tab() self.build_runner_tab() self.build_system_tab() self.build_action_area("Add", self.on_save) self.show_all()
def get_game_config(self): """Return the game configuration""" if self.requires: # Load the base game config required_game = get_game_by_field(self.requires, field="installer_slug") base_config = LutrisConfig( runner_slug=self.runner, game_config_id=required_game["configpath"] ) config = base_config.game_level else: config = {"game": {}} # Config update if "system" in self.script: config["system"] = self._substitute_config(self.script["system"]) if self.runner in self.script and self.script[self.runner]: config[self.runner] = self._substitute_config(self.script[self.runner]) launcher, launcher_config = self.get_game_launcher_config(self.interpreter.game_files) if launcher: config["game"][launcher] = launcher_config if "game" in self.script: try: config["game"].update(self.script["game"]) except ValueError: raise ScriptingError("Invalid 'game' section", self.script["game"]) config["game"] = self._substitute_config(config["game"]) if AUTO_ELF_EXE in config["game"].get("exe", ""): config["game"]["exe"] = find_linux_game_executable(self.interpreter.target_path, make_executable=True) elif AUTO_WIN32_EXE in config["game"].get("exe", ""): config["game"]["exe"] = find_windows_game_executable(self.interpreter.target_path) return config
def install_steam_game(self, runner_class=None, is_game_files=False): """Launch installation of a steam game. runner_class: class of the steam runner to use is_game_files: whether game data is added to game_files """ # Check if Steam is installed, save the method's arguments so it can # be called again once Steam is installed. self.steam_data['callback_args'] = (runner_class, is_game_files) steam_runner = self._get_steam_runner(runner_class) self.steam_data['is_game_files'] = is_game_files appid = self.steam_data['appid'] if not steam_runner.get_game_path_from_appid(appid): logger.debug("Installing steam game %s", appid) steam_runner.config = LutrisConfig(runner_slug=self.runner) if 'arch' in self.steam_data: steam_runner.config.game_config['arch'] = self.steam_data[ 'arch'] AsyncCall(steam_runner.install_game, None, appid, is_game_files) self.install_start_time = time.localtime() self.steam_poll = GLib.timeout_add( 2000, self._monitor_steam_game_install) self.abort_current_task = ( lambda: steam_runner.remove_game_data(appid=appid)) return 'STOP' elif is_game_files: self._append_steam_data_to_files(runner_class) else: self.target_path = self._get_steam_game_path()
def install_from_egs(self, egs_game, manifest): """Create a new Lutris game based on an existing EGS install""" app_name = manifest["AppName"] logger.debug("Installing EGS game %s", app_name) service_game = ServiceGameCollection.get_game("egs", app_name) if not service_game: logger.error("Aborting install, %s is not present in the game library.", app_name) return lutris_game_id = slugify(service_game["name"]) + "-" + self.id existing_game = get_game_by_field(lutris_game_id, "installer_slug") if existing_game: return game_config = LutrisConfig(game_config_id=egs_game["configpath"]).game_level game_config["game"]["args"] = get_launch_arguments(app_name) configpath = write_game_config(lutris_game_id, game_config) game_id = add_game( name=service_game["name"], runner=egs_game["runner"], slug=slugify(service_game["name"]), directory=egs_game["directory"], installed=1, installer_slug=lutris_game_id, configpath=configpath, service=self.id, service_id=app_name, ) return game_id
def install_from_steam(self, manifest): """Create a new Lutris game based on an existing Steam install""" if not manifest.is_installed(): return appid = manifest.steamid if appid in self.excluded_appids: return service_game = ServiceGameCollection.get_game(self.id, appid) if not service_game: return lutris_game_id = "%s-%s" % (self.id, appid) existing_game = get_game_by_field(lutris_game_id, "slug") if existing_game: return game_config = LutrisConfig().game_level game_config["game"]["appid"] = appid configpath = write_game_config(lutris_game_id, game_config) game_id = add_game( name=service_game["name"], runner="steam", slug=slugify(service_game["name"]), installed=1, installer_slug=lutris_game_id, configpath=configpath, platform="Linux", service=self.id, service_id=appid, ) return game_id
def mark_as_installed(scummvm_id, name, path): """Add scummvm from the auto-import""" logger.info("Setting %s as installed" % name) slug = slugify(name) config_id = make_game_config_id(slug) game_id = pga.add_or_update(name=name, runner='scummvm', installer_slug=INSTALLER_SLUG, slug=slug, installed=1, configpath=config_id, directory=path) config = LutrisConfig(runner_slug='scummvm', game_config_id=config_id) config.raw_game_config.update({'game_id': scummvm_id, 'path': path}) config.save() return game_id
def __init__(self, parent, game=None, runner=None, callback=None): super().__init__("Add a new game", parent=parent) self.game = game self.saved = False self.set_default_size(DIALOG_WIDTH, DIALOG_HEIGHT) if game: self.runner_name = game.runner_name self.slug = game.slug else: self.runner_name = runner self.slug = None self.game_config_id = self.get_config_id() self.lutris_config = LutrisConfig( runner_slug=self.runner_name, game_config_id=self.game_config_id, level="game", ) self.build_notebook() self.build_tabs("game") self.build_action_area(self.on_save, callback) self.name_entry.grab_focus() self.connect("delete-event", self.on_cancel_clicked) self.show_all()
def test_system_config_with_no_system_yml(self): def fake_yaml_reader(path): if not path: return {} if 'system.yml' in path: return {} if 'wine.yml' in path: return {'system': {'resolution': '800x600'}} if 'rage.yml' in path: return { 'system': { 'resolution': '1680x1050' }, 'runner': 'wine' } return {} with patch('lutris.config.read_yaml_from_file') as yaml_reader: yaml_reader.side_effect = fake_yaml_reader wine_runner = runners.import_runner('wine') game_config = LutrisConfig(game='rage') self.assertEqual(game_config.game, 'rage') self.assertEqual(game_config.runner, 'wine') wine = wine_runner(game_config) self.assertEqual(wine.system_config, {'resolution': '1680x1050'})
def __init__(self, parent, game=None): super(AddGameDialog, self).__init__() self.parent_window = parent self.lutris_config = LutrisConfig() self.runner_name = None self.set_title("Add a new game") self.set_size_request(600, 500) if game: name = game.name self.slug = game.slug else: name = None self.slug = None self.build_name_entry(name) self.build_runner_dropdown() self.build_notebook() self.build_game_tab() self.build_runner_tab() self.build_system_tab() self.build_action_area(Gtk.STOCK_ADD, self.save_game) self.show_all() self.run()
def get_default_target(self): """Return default installation dir""" config = LutrisConfig(runner_slug=self.installer.runner) games_dir = config.system_config.get("game_path", os.path.expanduser("~")) return os.path.expanduser( os.path.join(games_dir, self.installer.game_slug))
def __init__(self, parent=None): super().__init__(_("Lutris settings"), parent=parent) self.set_border_width(0) self.set_default_size(1010, 600) self.lutris_config = LutrisConfig() hbox = Gtk.HBox(visible=True) sidebar = Gtk.ListBox(visible=True) sidebar.connect("row-selected", self.on_sidebar_activated) sidebar.add( self.get_sidebar_button("prefs-stack", _("Interface"), "view-grid-symbolic")) sidebar.add( self.get_sidebar_button("runners-stack", _("Runners"), "applications-utilities-symbolic")) sidebar.add( self.get_sidebar_button("services-stack", _("Sources"), "application-x-addon-symbolic")) sidebar.add( self.get_sidebar_button("sysinfo-stack", _("Hardware information"), "computer-symbolic")) sidebar.add( self.get_sidebar_button("system-stack", _("Global options"), "emblem-system-symbolic")) hbox.pack_start(sidebar, False, False, 0) self.stack = Gtk.Stack(visible=True) self.stack.set_vhomogeneous(False) self.stack.set_interpolate_size(True) hbox.add(self.stack) self.vbox.pack_start(hbox, True, True, 0) self.stack.add_named(self.build_scrolled_window(PreferencesBox()), "prefs-stack") self.stack.add_named(self.build_scrolled_window(RunnersBox()), "runners-stack") self.stack.add_named(self.build_scrolled_window(ServicesBox()), "services-stack") self.stack.add_named(self.build_scrolled_window(SysInfoBox()), "sysinfo-stack") self.system_box = SystemBox(self.lutris_config) self.system_box.show_all() self.stack.add_named(self.build_scrolled_window(self.system_box), "system-stack") self.build_action_area(self.on_save) self.action_area.set_margin_bottom(12) self.action_area.set_margin_right(12) self.action_area.set_margin_left(12) self.action_area.set_margin_top(12)
def on_runner_changed(self, widget): """Action called when runner drop down is changed""" runner_index = widget.get_active() current_page = self.notebook.get_current_page() self.clear_tabs() if runner_index == 0: self.runner_name = None self.lutris_config = LutrisConfig() else: self.runner_name = widget.get_model()[runner_index][1] self.lutris_config = LutrisConfig(self.runner_name) self.build_game_tab() self.build_runner_tab() self.build_system_tab() self.notebook.set_current_page(current_page)
def on_runner_changed(self, widget): """Action called when runner drop down is changed.""" runner_index = widget.get_active() current_page = self.notebook.get_current_page() if runner_index == 0: self.runner_name = None self.lutris_config = LutrisConfig() else: self.runner_name = widget.get_model()[runner_index][1] self.lutris_config = LutrisConfig( runner_slug=self.runner_name, game_config_id=self.game_config_id, level='game') self._rebuild_tabs() self.notebook.set_current_page(current_page)
def install(self): success = super(atari800, self).install() if not success: return False config_path = os.path.expanduser("~/.atari800") if not os.path.exists(config_path): os.makedirs(config_path) bios_archive = os.path.join(config_path, 'atari800-bioses.zip') dlg = DownloadDialog(self.bios_url, bios_archive) dlg.run() if not os.path.exists(bios_archive): ErrorDialog("Could not download Atari800 BIOS archive") return extract.extract_archive(bios_archive, config_path) os.remove(bios_archive) config = LutrisConfig(runner_slug='atari800') config.raw_runner_config.update({'bios_path': config_path}) config.save()
def __init__(self): super(SystemConfigDialog, self).__init__("System preferences") self.set_size_request(500, 500) self.lutris_config = LutrisConfig() self.system_config_vbox = SystemBox(self.lutris_config, 'system') self.vbox.pack_start(self.system_config_vbox, True, True, 0) self.build_action_area("Save", self.save_config) self.show_all()
def test_custom_data_dir(self): scummvm_runner = scummvm() scummvm_runner.config = LutrisConfig() scummvm_runner.config.runner_config["datadir"] = "~/custom/scummvm" self.assertEqual(scummvm_runner.get_scummvm_data_dir(), "~/custom/scummvm") self.assertEqual(scummvm_runner.get_command()[1], "--extrapath=~/custom/scummvm")
class SystemConfigDialog(Dialog, GameDialogCommon): def __init__(self, parent=None): super().__init__("System preferences", parent=parent) self.game = None self.runner_name = None self.lutris_config = LutrisConfig() self.set_default_size(DIALOG_WIDTH, DIALOG_HEIGHT) self.build_notebook() self.build_tabs("system") self.build_action_area(self.on_save) self.show_all() def on_save(self, _widget): self.lutris_config.save() self.destroy()
def mark_as_installed(scummvm_id, name, path): """Add scummvm from the auto-import""" logger.info("Setting %s as installed", name) slug = slugify(name) config_id = make_game_config_id(slug) game_id = pga.add_or_update( name=name, runner="scummvm", installer_slug=INSTALLER_SLUG, slug=slug, installed=1, configpath=config_id, directory=path, ) config = LutrisConfig(runner_slug="scummvm", game_config_id=config_id) config.raw_game_config.update({"game_id": scummvm_id, "path": path}) config.save() return game_id
def load_config(self): """Load the game's configuration.""" self.config = LutrisConfig(game=self.slug) if self.is_installed: runner_class = import_runner(self.runner_name) if runner_class: self.runner = runner_class(self.config) else: logger.error("Unable to import runner %s", self.runner_name)
def write_config(self, _id, name, fullpath): """Write game configuration to settings directory.""" system = self.__class__.__name__ index = fullpath.rindex("/") exe = fullpath[index + 1:] path = fullpath[:index] if path.startswith("file://"): path = path[7:] config = LutrisConfig() config.config = { "main": { "path": path, "exe": exe, "realname": name, "runner": system } } config.save(config_type="game")
def load_config(self): """ Load the game's configuration. """ self.game_config = LutrisConfig(game=self.slug) if self.is_installed: if not self.game_config.is_valid(): logger.error("Invalid game config for %s" % self.slug) else: runner_class = import_runner(self.runner_name) self.runner = runner_class(self.game_config)
def on_runner_installed(*args): bios_path = system.create_folder('~/.hatari/bios') dlg = QuestionDialog({ 'question': "Do you want to select an Atari ST BIOS file?", 'title': "Use BIOS file?", }) if dlg.result == dlg.YES: bios_dlg = FileDialog("Select a BIOS file") bios_filename = bios_dlg.filename if not bios_filename: return shutil.copy(bios_filename, bios_path) bios_path = os.path.join(bios_path, os.path.basename(bios_filename)) config = LutrisConfig(runner_slug='hatari') config.raw_runner_config.update({'bios_file': bios_path}) config.save() if callback: callback()
class SystemConfigDialog(Dialog, GameDialogCommon): def __init__(self, parent=None): super(SystemConfigDialog, self).__init__("System preferences", parent=parent) self.game = None self.runner_name = None self.lutris_config = LutrisConfig() self.set_default_size(DIALOG_WIDTH, DIALOG_HEIGHT) self.system_box = SystemBox(self.lutris_config) self.system_sw = self.build_scrolled_window(self.system_box) self.vbox.pack_start(self.system_sw, True, True, 0) self.build_action_area(self.on_save) self.show_all() def on_save(self, widget): self.lutris_config.save() self.destroy()
class SystemConfigDialog(Gtk.Dialog, GameDialogCommon): title = "System preferences" dialog_height = 500 def __init__(self): super(SystemConfigDialog, self).__init__() self.set_title(self.title) self.set_size_request(500, self.dialog_height) self.lutris_config = LutrisConfig() self.system_config_vbox = SystemBox(self.lutris_config, 'system') self.vbox.pack_start(self.system_config_vbox, True, True, 0) self.build_action_area("Save", self.save_config) self.show_all() def save_config(self, widget): assert self.lutris_config.config_type == 'system' self.lutris_config.save() self.destroy()
class SystemConfigDialog(Dialog, GameDialogCommon): def __init__(self): super(SystemConfigDialog, self).__init__("System preferences") self.game = None self.runner_name = None self.lutris_config = LutrisConfig() self.set_default_size(DIALOG_WIDTH, DIALOG_HEIGHT) self.system_box = SystemBox(self.lutris_config) self.system_sw = self.build_scrolled_window(self.system_box) self.vbox.pack_start(self.system_sw, True, True, 0) self.build_action_area("Save", self.save_config) self.show_all() def save_config(self, widget): self.lutris_config.save() self.destroy()
def migrate(): games = pga.get_games(filter_installed=True) for game_info in games: if game_info["runner"] != "steam" or game_info["configpath"]: continue slug = game_info["slug"] config_id = make_game_config_id(slug) # Add configpath to db pga.add_or_update(name=game_info["name"], runner="steam", slug=slug, configpath=config_id) # Add appid to config game_config = LutrisConfig(runner_slug="steam", game_config_id=config_id) game_config.raw_game_config.update( {"appid": str(game_info["steamid"])}) game_config.save()
def mark_as_installed(steamid, runner_name, game_info): for key in ['name', 'slug']: assert game_info[key] logger.info("Setting %s as installed" % game_info['name']) config_id = (game_info.get('config_path') or make_game_config_id(game_info['slug'])) game_id = pga.add_or_update( steamid=int(steamid), name=game_info['name'], runner=runner_name, slug=game_info['slug'], installed=1, configpath=config_id, ) game_config = LutrisConfig( runner_slug=runner_name, game_config_id=config_id, ) game_config.raw_game_config.update({'appid': steamid}) game_config.save() return game_id
class RunnerConfigDialog(Dialog, GameDialogCommon): """Runner config edit dialog.""" def __init__(self, runner, parent=None): self.runner_name = runner.__class__.__name__ super().__init__("Configure %s" % runner.human_name, parent=parent) self.game = None self.saved = False self.lutris_config = LutrisConfig(runner_slug=self.runner_name) self.set_default_size(DIALOG_WIDTH, DIALOG_HEIGHT) self.build_notebook() self.build_tabs("runner") self.build_action_area(self.on_save) self.show_all() def on_save(self, wigdet, data=None): self.lutris_config.save() self.destroy()
class RunnerConfigDialog(Dialog, GameDialogCommon): """Runners management dialog.""" def __init__(self, runner): self.runner_name = runner.__class__.__name__ super(RunnerConfigDialog, self).__init__( "Configure %s" % self.runner_name ) self.game = None self.saved = False self.lutris_config = LutrisConfig(runner_slug=self.runner_name) self.set_default_size(DIALOG_WIDTH, DIALOG_HEIGHT) self.build_notebook() self.build_tabs('runner') self.build_action_area("Edit", self.ok_clicked) self.show_all() def ok_clicked(self, _wigdet): self.lutris_config.save() self.destroy()