def init(self, organizer: mobase.IOrganizer): BasicGame.init(self, organizer) self._featureMap[ mobase.ModDataChecker] = StalkerAnomalyModDataChecker() self._featureMap[ mobase.ModDataContent] = StalkerAnomalyModDataContent() self._featureMap[mobase.SaveGameInfo] = StalkerAnomalySaveGameInfo() organizer.onAboutToRun(lambda _str: self.aboutToRun(_str)) return True
def create_plugin_mapping_impl(organizer: mobase.IOrganizer) -> PluginMapping: pluginlist = organizer.pluginList() modlist = organizer.modList() data: PluginMapping = [] for plugin in pluginlist.pluginNames(): mod = pluginlist.origin(plugin) priority = pluginlist.priority(plugin) priority_mod = modlist.priority(mod) data.append((priority, plugin, priority_mod, mod)) return data
def __init__(self, tree: mobase.IFileTree, organizer: mobase.IOrganizer): self._organizer = organizer self._game = organizer.managedGame() checker: mobase.ModDataChecker = self._game.feature( mobase.ModDataChecker # type: ignore ) # Read the subpackages: self._subpackages = SubPackages() for entry in tree: if isinstance(entry, mobase.IFileTree): if checker: if checker.dataLooksValid( entry) == mobase.ModDataChecker.VALID: self._subpackages.append(MO2SubPackage(entry)) continue # Add entry with INI tweaks: if entry.exists("INI Tweaks") or entry.exists("INI"): self._subpackages.append(MO2SubPackage(entry)) continue # We add folder with format "XXX Docs" where "XXX" is a number. parts = entry.name().split() if (len(parts) >= 2 and parts[0].isdigit() and parts[1].lower().startswith("doc")): self._subpackages.append(MO2SubPackage(entry))
def __init__(self, organizer: IOrganizer, parent: QObject = None): super().__init__(parent) self._organizer = organizer self._isLoading = False organizer.pluginList().onRefreshed(self.onRefreshed) organizer.pluginList().onPluginMoved(self.onPluginMoved) organizer.pluginList().onPluginStateChanged(self.onPluginStateChanged) organizer.modList().onModStateChanged(self.onModStateChanged)
def __init__( self, context: WizardRequireVersionsContext, organizer: mobase.IOrganizer, parent: QtWidgets.QWidget, ): super().__init__(parent) self.context = context # Set the ui file: self.ui = Ui_WizardInstallerRequires() self.ui.setupUi(self) self.ui.groupBox.setStyleSheet( 'QLabel[headercell="true"] { font-weight: bold; }' ) game = organizer.managedGame() okIcon = QPixmap(":/MO/gui/checked-checkbox").scaled( 16, 16, Qt.KeepAspectRatio, Qt.SmoothTransformation ) noIcon = QPixmap(":/MO/gui/unchecked-checkbox").scaled( 16, 16, Qt.KeepAspectRatio, Qt.SmoothTransformation ) koIcon = QPixmap(":/MO/gui/indeterminate-checkbox").scaled( 16, 16, Qt.KeepAspectRatio, Qt.SmoothTransformation ) self.ui.labelGame.setText(game.gameName()) # Set the required version: self.ui.labelGameNeed.setText(context.game_version) self.ui.labelScriptExtenderNeed.setText(context.script_extender_version) self.ui.labelGraphicsExtenderNeed.setText(context.graphics_extender_version) self.ui.labelWryeBashNeed.setText(context.wrye_bash_version) # Set the current version: self.ui.labelGameHave.setText(game.version().canonicalString()) se = game.feature(mobase.ScriptExtender) # type: ignore if se or se.isInstalled(): self.ui.labelScriptExtenderHave.setText(se.getExtenderVersion()) # Cannot check these so... game_ok, se_ok, ge_ok, _ = check_version(context, organizer) self.ui.labelGameIcon.setPixmap(okIcon if game_ok else koIcon) self.ui.labelScriptExtenderIcon.setPixmap(okIcon if se_ok else koIcon) self.ui.labelGraphicsExtenderIcon.setPixmap(noIcon) self.ui.labelWryeBashIcon.setPixmap(noIcon)
def check_version( context: WizardRequireVersionsContext, organizer: mobase.IOrganizer ) -> Tuple[bool, bool, bool, bool]: """ Check if the requirements are ok. Args: context: The requires version context to check. organizer: The organizer to fetch actual versions from. Returns: A 4-tuple of boolean values, where each value is True if the installed version is ok, False otherwise. In order, checks are game, script extender graphics extender (True if there is no requirements, False otherwise since we cannot check in MO2), and wrye bash (always True). """ game = organizer.managedGame() game_ok = True if context.game_version: game_ok = mobase.VersionInfo(context.game_version) <= game.version() # Script extender: se_ok = True if context.script_extender_version: se = game.feature(mobase.ScriptExtender) # type: ignore if not se or not se.isInstalled(): se_ok = False else: if mobase.VersionInfo( context.script_extender_version ) <= mobase.VersionInfo(se.getExtenderVersion()): se_ok = True else: se_ok = False # Cannot check these so... ge_ok = not context.graphics_extender_version return (game_ok, se_ok, ge_ok, True)
def activate_plugins_impl(organizer: mobase.IOrganizer, plugins: List[str], plugin_to_mod: Dict[str, str]): modlist = organizer.modList() pluginlist = organizer.pluginList() # Disable all mods modlist.setActive(modlist.allMods(), active=False) enabled_plugins = set() enabled_mods = set() try: mods = [plugin_to_mod[p] for p in plugins] # Enable mods with selected plugins modlist.setActive(mods, active=True) # Enable only selected plugins def enable_plugins(plugins_to_enable): for p in pluginlist.pluginNames(): if p in plugins_to_enable: pluginlist.setState(p, mobase.PluginState.ACTIVE) else: pluginlist.setState(p, mobase.PluginState.INACTIVE) # Enable no plugins (except mandatory) enable_plugins([]) mandatory_plugins = [ p for p in pluginlist.pluginNames() if pluginlist.state(p) == mobase.PluginState.ACTIVE ] # Enable missing masters plugins_and_masters = set(mandatory_plugins) plugins_and_masters_to_check = set(plugins) # Checking masters of plugins (and their masters, and so on) while len(plugins_and_masters_to_check) > 0: plugins_and_masters.update(plugins_and_masters_to_check) # Extract all masters of plugins in the current loop for p in plugins_and_masters_to_check.copy(): masters = pluginlist.masters(p) plugins_and_masters_to_check.update(masters) # Remove all masters that were already checked in a previous loop plugins_and_masters_to_check.difference_update(plugins_and_masters) # Missing masters found -> enable mods and do another round checking them for masters if len(plugins_and_masters_to_check) > 0: additional_mods = set( [plugin_to_mod[p] for p in plugins_and_masters_to_check]) qInfo( f"Enabling {additional_mods} containing missing masters {plugins_and_masters_to_check}" .encode('ascii', 'replace').decode('ascii')) modlist.setActive(list(additional_mods), active=True) enabled_mods.update(additional_mods) except KeyError as e: raise PrepareMergeException(e.args[0]) # Enable only target plugins and their masters # Not other plugins inside the same mod enable_plugins(plugins_and_masters) enabled_plugins.update(plugins_and_masters) enabled_plugins.difference_update(mandatory_plugins) # Place plugins at end of load order max_priority = len(pluginlist.pluginNames()) - 1 for p in plugins: pluginlist.setPriority(p, max_priority) return list(enabled_plugins), list(enabled_mods)