Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Extensions #155

Open
wants to merge 5 commits into
base: dev/vcpkg
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
path: "basic_games"
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.12
- uses: abatilo/actions-poetry@v2
- name: Install
run: |
cd basic_games
poetry --no-root install
run: poetry --no-root install
- name: Lint
run: |
cd basic_games
poetry run poe lint
run: poetry run poe lint
15 changes: 6 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
cmake_minimum_required(VERSION 3.16)

if(DEFINED DEPENDENCIES_DIR)
include(${DEPENDENCIES_DIR}/modorganizer_super/cmake_common/mo2.cmake)
else()
include(${CMAKE_CURRENT_LIST_DIR}/../cmake_common/mo2.cmake)
endif()

project(basic_games LANGUAGES NONE)

find_package(mo2-cmake CONFIG REQUIRED)

mo2_configure_extension()

add_custom_target(basic_games ALL)
mo2_configure_python(basic_games
MODULE
TRANSLATIONS OFF)
mo2_configure_python(basic_games MODULE TRANSLATIONS ON)
21 changes: 21 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"configurePresets": [
{
"binaryDir": "${sourceDir}/vsbuild",
"toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"generator": "Visual Studio 17 2022",
"name": "vs2022-windows"
},
{
"cacheVariables": {
"VCPKG_MANIFEST_FEATURES": {
"type": "STRING",
"value": "standalone"
}
},
"inherits": "vs2022-windows",
"name": "vs2022-windows-standalone"
}
],
"version": 4
}
3 changes: 2 additions & 1 deletion __init__.py → basic_games/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
import site
import sys
import typing
from pathlib import Path

from .basic_game import BasicGame
from .basic_game_ini import BasicIniGame

site.addsitedir(os.path.join(os.path.dirname(__file__), "lib"))
site.addsitedir(Path(__file__).parent.parent.joinpath("lib").as_posix())


BasicGame.setup()
Expand Down
File renamed without changes.
File renamed without changes.
10 changes: 7 additions & 3 deletions basic_game.py → basic_games/basic_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing import Callable, Generic, TypeVar

import mobase
from PyQt6.QtCore import QDir, QFileInfo, QStandardPaths
from PyQt6.QtCore import QCoreApplication, QDir, QFileInfo, QStandardPaths
from PyQt6.QtGui import QIcon

from .basic_features.basic_save_game_info import (
Expand Down Expand Up @@ -253,7 +253,7 @@ def __init__(self, game: BasicGame):
game,
"Description",
"description",
lambda g: "Adds basic support for game {}.".format(g.gameName()),
lambda g: game.tr("Adds basic support for game {}.").format(g.gameName()),
)
self.gameName = BasicGameMapping(game, "GameName", "gameName")
self.gameShortName = BasicGameMapping(game, "GameShortName", "gameShortName")
Expand Down Expand Up @@ -424,6 +424,10 @@ def is_epic(self) -> bool:
def is_eadesktop(self) -> bool:
return self._mappings.eaDesktopContentId.has_value()

# Qt translation
def tr(self, value: str) -> str:
return QCoreApplication.translate("BasicGame", value)

# IPlugin interface:

def init(self, organizer: mobase.IOrganizer) -> bool:
Expand Down Expand Up @@ -468,7 +472,7 @@ def isActive(self) -> bool:
# Note: self is self._organizer.managedGame() does not work:
return self.name() == self._organizer.managedGame().name()

def settings(self) -> list[mobase.PluginSetting]:
def settings(self) -> list[mobase.Setting]:
return []

# IPluginGame interface:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -393,62 +393,72 @@ def listSaves(self, folder: QDir) -> list[mobase.ISaveGame]:
for path in Path(folder.absolutePath()).glob(f"**/*.{ext}")
]

def settings(self) -> list[mobase.PluginSetting]:
def settings(self) -> list[mobase.Setting]:
return [
mobase.PluginSetting(
mobase.Setting(
"skipStartScreen",
(
self.tr("Skip start screen"),
self.tr(
'Skips the "Breaching..." start screen on game launch'
" (can also skip loading of GOG rewards)"
),
False,
),
mobase.PluginSetting(
mobase.Setting(
"enforce_archive_load_order",
(
self.tr("Enforce archive load order"),
self.tr(
"Enforce the current load order via"
" <code>archive/pc/mod/modlist.txt</code>"
),
False,
),
mobase.PluginSetting(
mobase.Setting(
"reverse_archive_load_order",
(
self.tr("Reverse archive load order"),
self.tr(
"Reverse MOs load order in"
" <code>archive/pc/mod/modlist.txt</code>"
" (first loaded mod wins = last one / highest prio in MO)"
),
False,
),
mobase.PluginSetting(
mobase.Setting(
"enforce_redmod_load_order",
"Enforce the current load order on redmod deployment",
self.tr("Enforce RedMod load order"),
self.tr("Enforce the current load order on redmod deployment"),
True,
),
mobase.PluginSetting(
mobase.Setting(
"reverse_redmod_load_order",
(
self.tr("Reverse RedMod load order"),
self.tr(
"Reverse MOs load order on redmod deployment"
" (first loaded mod wins = last one / highest prio in MO)"
),
False,
),
mobase.PluginSetting(
mobase.Setting(
"auto_deploy_redmod",
"Deploy redmod before game launch if necessary",
self.tr("Auto deploy RedMod"),
self.tr("Deploy redmod before game launch if necessary"),
True,
),
mobase.PluginSetting(
mobase.Setting(
"clear_cache_after_game_update",
(
self.tr("Clear cache after game update"),
self.tr(
'Clears "overwrite/r6/cache/*" if the original game files changed'
" (after update)"
),
True,
),
mobase.PluginSetting(
mobase.Setting(
"configure_RootBuilder",
"Configures RootBuilder for Cyberpunk if installed and enabled",
self.tr("Configure RootBuilder"),
self.tr(
"Configures RootBuilder for Cyberpunk if installed and enabled"
),
True,
),
]
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,56 +1,56 @@
import mobase
from ..basic_game import BasicGame
class DaggerfallUnityModDataChecker(mobase.ModDataChecker):
def __init__(self):
super().__init__()
self.validDirNames = [
"biogs",
"docs",
"factions",
"fonts",
"mods",
"questpacks",
"quests",
"sound",
"soundfonts",
"spellicons",
"tables",
"text",
"textures",
"worlddata",
"aa",
]
def dataLooksValid(
self, filetree: mobase.IFileTree
) -> mobase.ModDataChecker.CheckReturn:
for entry in filetree:
if not entry.isDir():
continue
if entry.name().casefold() in self.validDirNames:
return mobase.ModDataChecker.VALID
return mobase.ModDataChecker.INVALID
class DaggerfallUnityGame(BasicGame):
def init(self, organizer: mobase.IOrganizer) -> bool:
super().init(organizer)
self._register_feature(DaggerfallUnityModDataChecker())
return True
Name = "Daggerfall Unity Support Plugin"
Author = "HomerSimpleton"
Version = "1.0.0"
GameName = "Daggerfall Unity"
GameShortName = "daggerfallunity"
GameBinary = "DaggerfallUnity.exe"
GameLauncher = "DaggerfallUnity.exe"
GameDataPath = "%GAME_PATH%/DaggerfallUnity_Data/StreamingAssets"
GameSupportURL = (
r"https://github.com/ModOrganizer2/modorganizer-basic_games/wiki/"
"Game:-Daggerfall-Unity"
)
import mobase

from ..basic_game import BasicGame


class DaggerfallUnityModDataChecker(mobase.ModDataChecker):
def __init__(self):
super().__init__()
self.validDirNames = [
"biogs",
"docs",
"factions",
"fonts",
"mods",
"questpacks",
"quests",
"sound",
"soundfonts",
"spellicons",
"tables",
"text",
"textures",
"worlddata",
"aa",
]

def dataLooksValid(
self, filetree: mobase.IFileTree
) -> mobase.ModDataChecker.CheckReturn:
for entry in filetree:
if not entry.isDir():
continue
if entry.name().casefold() in self.validDirNames:
return mobase.ModDataChecker.VALID
return mobase.ModDataChecker.INVALID


class DaggerfallUnityGame(BasicGame):
def init(self, organizer: mobase.IOrganizer) -> bool:
super().init(organizer)
self._register_feature(DaggerfallUnityModDataChecker())
return True

Name = "Daggerfall Unity Support Plugin"
Author = "HomerSimpleton"
Version = "1.0.0"

GameName = "Daggerfall Unity"
GameShortName = "daggerfallunity"
GameBinary = "DaggerfallUnity.exe"
GameLauncher = "DaggerfallUnity.exe"
GameDataPath = "%GAME_PATH%/DaggerfallUnity_Data/StreamingAssets"
GameSupportURL = (
r"https://github.com/ModOrganizer2/modorganizer-basic_games/wiki/"
"Game:-Daggerfall-Unity"
)
62 changes: 31 additions & 31 deletions games/game_dao.py → basic_games/games/game_dao.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
import mobase
from ..basic_features import BasicGameSaveGameInfo
from ..basic_game import BasicGame
class DAOriginsGame(BasicGame):
Name = "Dragon Age Origins Support Plugin"
Author = "Patchier"
Version = "1.1.1"
GameName = "Dragon Age: Origins"
GameShortName = "dragonage"
GameBinary = r"bin_ship\DAOrigins.exe"
GameDataPath = r"%DOCUMENTS%\BioWare\Dragon Age\packages\core\override"
GameSavesDirectory = r"%DOCUMENTS%\BioWare\Dragon Age\Characters"
GameSaveExtension = "das"
GameSteamId = [17450, 47810]
GameGogId = 1949616134
GameEaDesktopId = [70377, 70843]
GameSupportURL = (
r"https://github.com/ModOrganizer2/modorganizer-basic_games/wiki/"
"Game:-Dragon-Age:-Origins"
)
def init(self, organizer: mobase.IOrganizer):
super().init(organizer)
self._register_feature(
BasicGameSaveGameInfo(lambda s: s.parent.joinpath("screen.dds"))
)
return True
import mobase

from ..basic_features import BasicGameSaveGameInfo
from ..basic_game import BasicGame


class DAOriginsGame(BasicGame):
Name = "Dragon Age Origins Support Plugin"
Author = "Patchier"
Version = "1.1.1"

GameName = "Dragon Age: Origins"
GameShortName = "dragonage"
GameBinary = r"bin_ship\DAOrigins.exe"
GameDataPath = r"%DOCUMENTS%\BioWare\Dragon Age\packages\core\override"
GameSavesDirectory = r"%DOCUMENTS%\BioWare\Dragon Age\Characters"
GameSaveExtension = "das"
GameSteamId = [17450, 47810]
GameGogId = 1949616134
GameEaDesktopId = [70377, 70843]
GameSupportURL = (
r"https://github.com/ModOrganizer2/modorganizer-basic_games/wiki/"
"Game:-Dragon-Age:-Origins"
)

def init(self, organizer: mobase.IOrganizer):
super().init(organizer)
self._register_feature(
BasicGameSaveGameInfo(lambda s: s.parent.joinpath("screen.dds"))
)
return True
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading
Loading