Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanFeenstra committed Jul 11, 2023
0 parents commit bb215ac
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Lint

on: [push, pull_request]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v2
with:
python-version: "3.10"
- uses: psf/black@stable
with:
black_args: ". --check"
15 changes: 15 additions & 0 deletions .github/workflows/isort.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Run isort

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: "3.10"
- uses: isort/[email protected]
with:
configuration: "--profile black --line-length 125"
34 changes: 34 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Release

on:
push:
tags:
- "v*.*.*"

jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- run: |
echo ${{ format('ARCHIVE=Auto-Activator-{0}.zip', github.ref_name) }} >> $env:GITHUB_ENV
echo "RELEASE_NOTES<<EOF" >> $env:GITHUB_ENV
jq -r .Versions[-1].ReleaseNotes[] .\manifest.json >> $env:GITHUB_ENV
echo "EOF" >> $env:GITHUB_ENV
- run: |
echo "RELEASE_NOTES<<EOF" >> $env:GITHUB_ENV
echo $env:RELEASE_NOTES | foreach {"* " + $_} >> $env:GITHUB_ENV
echo "EOF" >> $env:GITHUB_ENV
if: contains(env.RELEASE_NOTES, '\n')
- name: Zip
run: |
7z a -tzip -mx9 $env:ARCHIVE auto_activator.py LICENSE README.md
- name: Create Release
uses: softprops/action-gh-release@v1
with:
body: ${{ env.RELEASE_NOTES }}
draft: true
prerelease: ${{ endsWith(github.ref_name, 'alpha') || endsWith(github.ref_name, 'beta') }}
files: ${{ env.ARCHIVE }}
fail_on_unmatched_files: true
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.mypy_cache/
.vscode/
__pycache__/
env/
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Auto-Activator
[Mod Organizer 2](https://github.com/ModOrganizer2/modorganizer) plugin to automatically activate mods on installation.

This is now possible thanks to a [bugfix](https://github.com/ModOrganizer2/modorganizer/pull/1837) in version 2.5.0 of Mod Organizer, which has not yet been released at the time of writing. As such, this plugin currently only works with pre-release builds of Mod Organizer v2.5.
47 changes: 47 additions & 0 deletions auto_activator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"""
Auto-Activator Plugin for Mod Organizer 2
Copyright (C) 2023 Jonathan Feenstra
"""
import mobase
from PyQt6.QtCore import qCritical
from PyQt6.QtWidgets import QApplication


class AutoActivator(mobase.IPlugin):
def __init__(self) -> None:
super().__init__()

def init(self, organizer: mobase.IOrganizer) -> bool:
self.__organizer = organizer

if not self.__organizer.modList().onModInstalled(self.__onModInstalled):
qCritical("Failed to install onModInstalled callback.")
return False

return True

def name(self) -> str:
return "Auto-Activator"

def author(self) -> str:
return "Jonathan Feenstra"

def description(self) -> str:
return self.__tr("Automatically activate mods after installing.")

def version(self) -> mobase.VersionInfo:
return mobase.VersionInfo(1, 0, 0, mobase.ReleaseType.FINAL)

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

def __onModInstalled(self, mod: mobase.IModInterface) -> None:
self.__organizer.modList().setActive(name=mod.name(), active=True)

def __tr(self, txt: str) -> str:
return QApplication.translate("AutoActivator", txt)


def createPlugin() -> mobase.IPlugin:
return AutoActivator()
13 changes: 13 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[tool.black]
line-length = 125
target-version = ["py310"]

[tool.isort]
profile = "black"
line_length = 125

[tool.pylint.messages_control]
disable = "C0330, C0326, C0111, W0212"

[tool.pylint.format]
max-line-length = "125"

0 comments on commit bb215ac

Please sign in to comment.