Skip to content

Commit

Permalink
Add a toggle option for LOOT warnings to the tools menu
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanFeenstra committed Jul 9, 2022
1 parent 2296f22 commit 47b4f1b
Show file tree
Hide file tree
Showing 8 changed files with 156 additions and 14 deletions.
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=LOOT-Warning-Checker-{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 img LOOT-Warning-Checker 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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.mypy_cache/
.vscode/
__pycache__/
__pycache__/
env/
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Plugin
======
Checker Plugin
==============
The LOOT Warning Checker plugin.
Expand Down Expand Up @@ -45,6 +45,9 @@ def init(self, organizer: mobase.IOrganizer) -> bool:
if not self.__organizer.onUserInterfaceInitialized(self.__onUserInterfaceInitialized):
qCritical(self.__tr("Failed to register onUserInterfaceInitialized callback."))
return False
if not self.__organizer.onPluginSettingChanged(self.__onPluginSettingChanged):
qCritical(self.__tr("Failed to register onPluginSettingChanged callback."))
return False
return True

def name(self) -> str:
Expand All @@ -57,12 +60,10 @@ def description(self) -> str:
return self.__tr("Checks for LOOT warnings.")

def version(self) -> mobase.VersionInfo:
return mobase.VersionInfo(1, 2, 1, mobase.ReleaseType.BETA)
return mobase.VersionInfo(1, 2, 2, mobase.ReleaseType.BETA)

def requirements(self) -> List[mobase.IPluginRequirement]:
return [
mobase.PluginRequirementFactory.gameDependency(games=list(SUPPORTED_GAMES.keys())),
]
return [mobase.PluginRequirementFactory.gameDependency(games=list(SUPPORTED_GAMES.keys()))]

def settings(self) -> List[mobase.PluginSetting]:
return [
Expand All @@ -84,7 +85,10 @@ def settings(self) -> List[mobase.PluginSetting]:
]

def activeProblems(self) -> List[int]:
if self.__lootLoader is None:
if self.__lootLoader is None or (
self.__organizer.isPluginEnabled("LOOT Warning Toggle")
and not self.__organizer.pluginSetting("LOOT Warning Toggle", "enable-warnings")
):
return []
self.__warnings = dict(
enumerate(
Expand All @@ -111,7 +115,7 @@ def startGuidedFix(self, key: int) -> None:
# TODO: Implement more guided fixes

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

def __onUserInterfaceInitialized(self, mainWindow: QMainWindow) -> None:
self.__parentWidget = mainWindow
Expand All @@ -132,6 +136,15 @@ def __onUserInterfaceInitialized(self, mainWindow: QMainWindow) -> None:
except OSError as exc:
qCritical(str(exc))

def __onPluginSettingChanged(
self, pluginName: str, settingName: str, oldValue: mobase.MoVariant, newValue: mobase.MoVariant
) -> None:
if pluginName == "LOOT Warning Toggle" and settingName == "enable-warnings":
if oldValue and not newValue:
self._invalidate()
else:
self.__organizer.refresh()

def __quickAutoCleanPlugin(self, pluginName: str) -> None:
"""Use xEdit's Quick Auto Clean mode to clean the plugin.
Expand Down
76 changes: 76 additions & 0 deletions LOOT-Warning-Checker/TogglePlugin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
"""
Toggle Plugin
=============
The plugin to toggle LOOT warnings.
Copyright (C) 2021-2022 Jonathan Feenstra
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
from typing import List, Optional
import mobase

from PyQt5.QtWidgets import QApplication, QWidget
from PyQt5.QtGui import QIcon
from .Games import SUPPORTED_GAMES


class LOOTWarningToggle(mobase.IPluginTool):
def __init__(self) -> None:
super().__init__()
self.__parentWidget: Optional[QWidget] = None

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

def name(self) -> str:
return "LOOT Warning Toggle"

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

def description(self) -> str:
return self.__tr("Toggles LOOT warnings.")

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

def requirements(self) -> List[mobase.IPluginRequirement]:
return [mobase.PluginRequirementFactory.gameDependency(games=list(SUPPORTED_GAMES.keys()))]

def settings(self) -> List[mobase.PluginSetting]:
return [mobase.PluginSetting("enable-warnings", self.__tr("Enable LOOT warnings"), True)]

def display(self) -> None:
self.__organizer.setPluginSetting(self.name(), "enable-warnings", not self.__warningsEnabled())

def displayName(self) -> str:
return self.__tr(f"{'Disable' if self.__warningsEnabled() else 'Enable'} LOOT warnings")

def icon(self) -> QIcon:
return QIcon("plugins/LOOT-Warning-Checker/resources/icon.ico")

def setParentWidget(self, parent: QWidget) -> None:
self.__parentWidget = parent

def tooltip(self) -> str:
return self.__tr("Toggles checking for LOOT warnings from the LOOT Warning Checker plugin.")

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

def __warningsEnabled(self) -> bool:
return self.__organizer.pluginSetting(self.name(), "enable-warnings") # type: ignore
9 changes: 6 additions & 3 deletions LOOT-Warning-Checker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@
import os
import site

from typing import List

site.addsitedir(os.path.join(os.path.dirname(__file__), "lib"))

from mobase import IPlugin

from .Plugin import LOOTWarningChecker
from .CheckerPlugin import LOOTWarningChecker
from .TogglePlugin import LOOTWarningToggle


def createPlugin() -> IPlugin:
return LOOTWarningChecker()
def createPlugins() -> List[IPlugin]:
return [LOOTWarningChecker(), LOOTWarningToggle()]
Binary file added LOOT-Warning-Checker/resources/icon.ico
Binary file not shown.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@

## Features
- Parse LOOT's masterlist and userlist to diagnose your modlist for warnings
- Display the warnings as notifications in Mod Organizer
- Guided fix for cleaning dirty plugins using [xEdit](https://github.com/TES5Edit/TES5Edit) (unless a manual fix is required)
- Configurable settings to:
- Enable/disable automatically updating LOOT's masterlist
- Enable/disable displaying non-warning messages
- Guided fix for cleaning dirty plugins using [xEdit](https://github.com/TES5Edit/TES5Edit), unless a manual fix is required
- Tool menu option to quickly toggle whether to check for LOOT warnings
- Support for:
- Morrowind
- Oblivion
Expand All @@ -28,4 +30,4 @@
- Fallout 4 VR

## Installation
Add the [LOOT-Warning-Checker folder](/LOOT-Warning-Checker) to your Mod Organizer 2 plugins folder or install it using [Kezyma's Plugin Finder](https://www.nexusmods.com/skyrimspecialedition/mods/59869).
Add the [LOOT-Warning-Checker folder](/LOOT-Warning-Checker) to your Mod Organizer plugins folder or install it using [Kezyma's Plugin Finder](https://www.nexusmods.com/skyrimspecialedition/mods/59869). Remove the contents of the existing folder before updating to a newer version.
13 changes: 13 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,19 @@
"ReleaseNotes": [
"Update masterlist directory path"
]
},
{
"Version": "1.2.2-beta",
"Released": "2022-07-09",
"MinSupport": "2.4.3",
"MaxSupport": "2.4.4",
"DownloadUrl": "https://github.com/JonathanFeenstra/modorganizer-loot-warning-checker/releases/download/v1.2.2-beta/LOOT-Warning-Checker-v1.2.2-beta.zip",
"PluginPath": [
"LOOT-Warning-Checker"
],
"ReleaseNotes": [
"Add a toggle option for LOOT warnings to the tools menu"
]
}
]
}

0 comments on commit 47b4f1b

Please sign in to comment.