Ejemplo n.º 1
0
 def compareGameVersion(self, version: str) -> int:
     v1 = mobase.VersionInfo(version)
     v2 = mobase.VersionInfo(self._game.gameVersion())
     if v1 < v2:
         return 1
     elif v1 > v2:
         return -1
     else:
         return 0
Ejemplo n.º 2
0
 def compareSEVersion(self, version: str) -> int:
     se = self._game.feature(mobase.ScriptExtender)  # type: ignore
     if not se:
         return 1
     v1 = mobase.VersionInfo(version)
     v2 = mobase.VersionInfo(se.getExtenderVersion())
     if v1 < v2:
         return 1
     elif v1 > v2:
         return -1
     else:
         return 0
    def __init__(self, game: "BasicGame"):
        self._game = game

        self.name = BasicGameMapping(game, "Name", "name")
        self.author = BasicGameMapping(game, "Author", "author")
        self.version = BasicGameMapping(
            game,
            "Version",
            "version",
            apply_fn=lambda s: mobase.VersionInfo(s) if isinstance(s, str) else s,
        )
        self.description = BasicGameMapping(
            game,
            "Description",
            "description",
            lambda g: "Adds basic support for game {}.".format(g.gameName()),
        )
        self.gameName = BasicGameMapping(game, "GameName", "gameName")
        self.gameShortName = BasicGameMapping(game, "GameShortName", "gameShortName")
        self.gameNexusName = BasicGameMapping(
            game, "GameNexusName", "gameNexusName", default=lambda g: g.gameShortName(),
        )
        self.validShortNames = BasicGameMapping(
            game,
            "GameValidShortNames",
            "validShortNames",
            default=lambda g: [],
            apply_fn=lambda value: [c.strip() for c in value.split(",")]  # type: ignore
            if isinstance(value, str)
            else value,
        )
        self.nexusGameId = BasicGameMapping(
            game, "GameNexusId", "nexusGameID", default=lambda g: 0, apply_fn=int
        )
        self.binaryName = BasicGameMapping(game, "GameBinary", "binaryName")
        self.launcherName = BasicGameMapping(
            game, "GameLauncher", "getLauncherName", default=lambda g: "",
        )
        self.dataDirectory = BasicGameMapping(game, "GameDataPath", "dataDirectory")
        self.documentsDirectory = BasicGameMapping(
            game,
            "GameDocumentsDirectory",
            "documentsDirectory",
            apply_fn=lambda s: QDir(s) if isinstance(s, str) else s,
            default=BasicGameMappings._default_documents_directory,
        )
        self.savesDirectory = BasicGameMapping(
            game,
            "GameSavesDirectory",
            "savesDirectory",
            apply_fn=lambda s: QDir(s) if isinstance(s, str) else s,
            default=lambda g: g.documentsDirectory(),
        )
        self.savegameExtension = BasicGameMapping(
            game, "GameSaveExtension", "savegameExtension", default=lambda g: "save"
        )
        self.steamAPPId = BasicGameMapping(
            game, "GameSteamId", "steamAPPId", default=lambda g: "", apply_fn=str
        )
    def display(self):
        if self.__organizer.appVersion() >= mobase.VersionInfo(2, 4, 0):
            allModsByProfilePriority = self.__organizer.modList(
            ).allModsByProfilePriority
        else:
            allModsByProfilePriority = self.__organizer.modsSortedByProfilePriority

        # We should test if the current game is compatible with OpenMW here
        # We can't do that directly, so instead we just test if the current game is Morrowind
        game = self.__organizer.managedGame()
        if game.gameName() != "Morrowind":
            QMessageBox.critical(
                self.__parentWidget, self.__tr("Incompatible game"),
                self.__tr(
                    "(At least when this plugin is being written) OpenMW only supports game data designed for the Morrowind engine. The game being managed is not Morrowind, so the export will abort. If you think you know better than this message, update this plugin."
                ))
            return
        # Give the user the opportunity to abort
        confirmationButton = QMessageBox.question(
            self.__parentWidget, self.__tr("Before starting export..."),
            self.__tr(
                "Before starting the export to OpenMW, please ensure you've backed up anything in OpenMW.cfg which you do not want to risk losing forever."
            ),
            QMessageBox.StandardButtons(QMessageBox.Ok | QMessageBox.Cancel))
        if confirmationButton != QMessageBox.Ok:
            return
        # Get the path to the OpenMW.cfg file
        configPath = self.__getOpenMWConfigPath()
        if not configPath.is_file():
            QMessageBox.critical(self.__parentWidget,
                                 self.__tr("Config file not specified"),
                                 self.__tr("No config file was specified"))
            return
        # Clear out the existing data= and content= lines from openmw.cfg
        self.__clearOpenMWConfig(configPath)
        with configPath.open("a", encoding="utf-8") as openmwcfg:
            # write out data directories
            openmwcfg.write(
                self.__processDataPath(game.dataDirectory().absolutePath()))
            for mod in allModsByProfilePriority():
                self.__processMod(openmwcfg, mod)
            self.__processMod(openmwcfg, "Overwrite")

            # write out content (plugin) files
            # order content files by load order
            loadOrder = {}
            for plugin in self.__organizer.pluginList().pluginNames():
                loadIndex = self.__organizer.pluginList().loadOrder(plugin)
                if loadIndex >= 0:
                    loadOrder[loadIndex] = plugin
            # actually write out the list
            for pluginIndex in range(len(loadOrder)):
                openmwcfg.write("content=" + loadOrder[pluginIndex] + "\n")
        QMessageBox.information(
            self.__parentWidget, self.__tr("OpenMW Export Complete"),
            self.__tr(
                "The export to OpenMW completed successfully. The current setup was saved to {0}"
            ).format(configPath))
Ejemplo n.º 5
0
 def __onDescriptionReceived(self, gameName, modID, userData, resultData):
     version = mobase.VersionInfo(resultData["version"])
     if self.version() < version:
         response = QMessageBox.question(
             self._parentWidget(), self.__tr("Plugin update available"),
             self.__tr(
                 "{0} can be updated from version {1} to {2}. Do you want to open the download page in your browser?"
             ).format(self.displayName(), self.version(), version))
         if response == QMessageBox.Yes:
             QDesktopServices.openUrl(
                 QUrl("https://www.nexusmods.com/morrowind/mods/45642"))
Ejemplo n.º 6
0
 def init(self, organizer):
     self.__organizer = organizer
     if sys.version_info < (3, 6):
         qCritical(self.__tr("OpenMWExport plugin requires a Python {0} interpreter or newer, but is running on a Python {1} interpreter.").format("3.6", ".".join(map(str, sys.version_info[:3]))))
         QMessageBox.critical(self._parentWidget(), self.__tr("Incompatible Python version."), self.__tr("This version of the OpenMW Export plugin requires a Python {0} interpreter or newer, but Mod Organizer has provided a Python {1} interpreter. Mod Organizer {2} is the earliest compatible version. You should check for an update.").format("3.6", ".".join(map(str, sys.version_info[:3])), "2.1.6"))
         return False
     if self.__organizer.appVersion() >= mobase.VersionInfo(2, 3, 1):
         self.__nexusBridge = self.__organizer.createNexusBridge()
         self.__nexusBridge.descriptionAvailable.connect(self.__onDescriptionReceived)
         self.__organizer.onUserInterfaceInitialized(self.__checkForUpdate)
     return True
    def __processMod(self, configFile, modName):
        if self.__organizer.appVersion() >= mobase.VersionInfo(2, 4, 0):
            getMod = self.__organizer.modList().getMod
        else:
            getMod = self.__organizer.getMod

        state = self.__organizer.modList().state(modName)
        if (state & 0x2) != 0 or modName == "Overwrite":
            path = getMod(modName).absolutePath()
            configLine = self.__processDataPath(path)
            configFile.write(configLine)
Ejemplo n.º 8
0
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 version(self) -> mobase.VersionInfo:
     return mobase.VersionInfo(1, 0, 0, mobase.ReleaseType.FINAL)
 def version(self):
     # Don't forget to import mobase!
     return mobase.VersionInfo(1, 0, 0, mobase.ReleaseType.final)
Ejemplo n.º 11
0
 def version(self):
     return mobase.VersionInfo(0, 1, 0, mobase.ReleaseType.PRE_ALPHA)
Ejemplo n.º 12
0
    def __init__(self, game: "BasicGame"):
        self._game = game

        self.name = BasicGameMapping(game, "Name", "name")
        self.author = BasicGameMapping(game, "Author", "author")
        self.version = BasicGameMapping(
            game,
            "Version",
            "version",
            apply_fn=lambda s: mobase.VersionInfo(s)
            if isinstance(s, str) else s,
        )
        self.description = BasicGameMapping(
            game,
            "Description",
            "description",
            lambda g: "Adds basic support for game {}.".format(g.gameName()),
        )
        self.gameName = BasicGameMapping(game, "GameName", "gameName")
        self.gameShortName = BasicGameMapping(game, "GameShortName",
                                              "gameShortName")
        self.gameNexusName = BasicGameMapping(
            game,
            "GameNexusName",
            "gameNexusName",
            default=lambda g: g.gameShortName(),
        )
        self.validShortNames = BasicGameMapping(
            game,
            "GameValidShortNames",
            "validShortNames",
            default=lambda g: [],
            apply_fn=lambda value: [c.strip()
                                    for c in value.split(",")]  # type: ignore
            if isinstance(value, str) else value,
        )
        self.nexusGameId = BasicGameMapping(game,
                                            "GameNexusId",
                                            "nexusGameID",
                                            default=lambda g: 0,
                                            apply_fn=int)
        self.binaryName = BasicGameMapping(game, "GameBinary", "binaryName")
        self.launcherName = BasicGameMapping(
            game,
            "GameLauncher",
            "getLauncherName",
            default=lambda g: "",
        )
        self.dataDirectory = BasicGameMapping(game, "GameDataPath",
                                              "dataDirectory")
        self.documentsDirectory = BasicGameMapping(
            game,
            "GameDocumentsDirectory",
            "documentsDirectory",
            apply_fn=lambda s: QDir(s) if isinstance(s, str) else s,
            default=BasicGameMappings._default_documents_directory,
        )
        self.savesDirectory = BasicGameMapping(
            game,
            "GameSavesDirectory",
            "savesDirectory",
            apply_fn=lambda s: QDir(s) if isinstance(s, str) else s,
            default=lambda g: g.documentsDirectory(),
        )
        self.savegameExtension = BasicGameMapping(game,
                                                  "GameSaveExtension",
                                                  "savegameExtension",
                                                  default=lambda g: "save")

        # Convert Union[int, str, List[Union[int, str]]] to List[str].
        def ids_apply(v) -> List[str]:
            if isinstance(v, (int, str)):
                v = [v]
            return [str(x) for x in v]

        self.steamAPPId = BasicGameOptionsMapping(game,
                                                  "GameSteamId",
                                                  "steamAPPId",
                                                  default=lambda g: "",
                                                  apply_fn=ids_apply)
        self.gogAPPId = BasicGameOptionsMapping(game,
                                                "GameGogId",
                                                "gogAPPId",
                                                default=lambda g: "",
                                                apply_fn=ids_apply)
        self.originManifestIds = BasicGameOptionsMapping(
            game,
            "GameOriginManifestIds",
            "originManifestIds",
            default=lambda g: "",
            apply_fn=ids_apply,
        )
        self.originWatcherExecutables = BasicGameMapping(
            game,
            "GameOriginWatcherExecutables",
            "originWatcherExecutables",
            apply_fn=lambda s: [s] if isinstance(s, str) else s,
            default=lambda g: [],
        )
 def version(self):
     return mobase.VersionInfo(3, 1, 0, mobase.ReleaseType.BETA)
Ejemplo n.º 14
0
 def version(self):
     return mobase.VersionInfo(3, 0, 0, mobase.ReleaseType.FINAL)
Ejemplo n.º 15
0
 def version(self):
     """
     @return version of the plugin. This can be used to detect outdated versions of
     plugins.
     """
     return mobase.VersionInfo(0, 1, 0, mobase.ReleaseType.prealpha)
Ejemplo n.º 16
0
 def version(self):
     return mobase.VersionInfo(1, 0, 0, mobase.ReleaseType.final)
Ejemplo n.º 17
0
 def version(self):
     return mobase.VersionInfo(1, 0, 2)