8 Commits
Author SHA1 Message Date
Mikaël Capelle 0c8d7261fd Merge pull request #3 from Holt59/update-interpreter
Update interpreter to fix issues with case-sensitive comparisons.
2022-02-05 14:33:38 +01:00
Mikaël Capelle 3cf15300fb Update interpreter to fix issues with case-sensitive comparisons. 2022-02-05 14:31:39 +01:00
Mikaël Capelle fb91a1d2b6 Merge pull request #2 from Holt59/fix-optional-plugins
Fix not-selected plugins
2021-03-13 13:49:42 +01:00
Mikaël Capelle 9f71ac1517 Move not-selected plugins to 'optional'. 2021-03-13 13:48:45 +01:00
Mikaël Capelle 775d764950 Fix translations. 2021-02-06 19:28:26 +01:00
Mikaël Capelle 538a0f73e9 Make placeholder text not-translatable. 2021-02-03 18:35:19 +01:00
Mikaël Capelle ecefc5eb8a Fix FOMOD/OMOD detection. 2020-11-27 20:30:06 +01:00
Mikaël Capelle b9653b8322 Merge pull request #1 from ModOrganizer2/cmake-common
Add CMakeLists for MO2 build.
2020-11-25 17:51:27 +01:00
12 changed files with 105 additions and 93 deletions
+1 -1
View File
@@ -1 +1 @@
git+https://github.com/Holt59/bain-wizard-interpreter
git+https://github.com/Holt59/bain-wizard-interpreter@v0.0.3
+1 -1
View File
@@ -4,4 +4,4 @@ mypy
flake8
flake8-black
mobase-stubs
git+https://github.com/Holt59/bain-wizard-interpreter
git+https://github.com/Holt59/bain-wizard-interpreter.git@v0.0.3
+2 -2
View File
@@ -37,8 +37,8 @@ deps =
mypy
flake8
flake8-black
mobase-stubs==2.4.0.a3
git+https://github.com/Holt59/bain-wizard-interpreter
mobase-stubs==2.4.0
git+https://github.com/Holt59/bain-wizard-interpreter@v0.0.3
commands =
black src --check --diff --exclude "lib" --exclude "ui"
flake8 src
+37 -31
View File
@@ -1,36 +1,35 @@
# -*- encoding: utf-8 -*-
from pathlib import Path
from typing import Any, List, Mapping, Optional, Tuple
from PyQt5.QtCore import Qt, pyqtSignal
from PyQt5.QtGui import QPixmap, QKeySequence, QFontDatabase
from PyQt5 import QtWidgets
from typing import Any, Dict, List, Mapping, Optional, Set, Tuple
import mobase
from .ui.wizardinstallerdialog import Ui_WizardInstallerDialog
from .ui.wizardinstallerpage import Ui_WizardInstallerPage
from .ui.wizardinstallerrequires import Ui_WizardInstallerRequires
from .ui.wizardinstallercomplete import Ui_WizardInstallerComplete
from .ui.wizardinstallererror import Ui_WizardInstallerError
from antlr4 import ParserRuleContext
from PyQt5 import QtWidgets
from PyQt5.QtCore import Qt, pyqtSignal
from PyQt5.QtGui import QFontDatabase, QKeySequence, QPixmap
from PyQt5.QtWidgets import QApplication
from wizard.contexts import (
WizardInterpreterContext,
WizardTopLevelContext,
WizardSelectContext,
WizardSelectOneContext,
WizardSelectManyContext,
WizardRequireVersionsContext,
WizardSelectContext,
WizardSelectManyContext,
WizardSelectOneContext,
WizardTerminationContext,
WizardTopLevelContext,
)
from wizard.errors import WizardError
from wizard.interpreter import WizardInterpreter
from wizard.manager import SelectOption
from wizard.runner import WizardRunnerState, WizardRunnerKeywordVisitor
from wizard.runner import WizardRunnerKeywordVisitor, WizardRunnerState
from wizard.tweaks import WizardINISetting
from wizard.value import Plugin
from .ui.wizardinstallercomplete import Ui_WizardInstallerComplete
from .ui.wizardinstallerdialog import Ui_WizardInstallerDialog
from .ui.wizardinstallererror import Ui_WizardInstallerError
from .ui.wizardinstallerpage import Ui_WizardInstallerPage
from .ui.wizardinstallerrequires import Ui_WizardInstallerRequires
from .utils import make_ini_tweaks
WizardRunnerContext = WizardInterpreterContext[WizardRunnerState, Any]
@@ -278,7 +277,7 @@ class WizardInstallerCompletePage(QtWidgets.QWidget):
kvisitor: WizardRunnerKeywordVisitor = context.factory.kvisitor # type: ignore
# The list of plugins in selected sub-packages:
plugins: List[str] = []
plugins: Set[Plugin] = set()
# SubPackages:
for sp in kvisitor.subpackages:
@@ -289,13 +288,19 @@ class WizardInstallerCompletePage(QtWidgets.QWidget):
else:
item.setCheckState(Qt.Unchecked)
item.setFlags(item.flags() & ~Qt.ItemIsUserCheckable) # type: ignore
plugins.extend(kvisitor.plugins_for(sp))
plugins.update(kvisitor.plugins_for(sp))
self.ui.subpackagesList.addItem(item)
# Switch the renamed plugins:
for plugin in list(plugins):
if plugin in self.state.renames:
plugins.remove(plugin)
plugins.add(Plugin(self.state.renames[plugin]))
# Plugins:
for plugin in sorted(plugins):
item = QtWidgets.QListWidgetItem()
item.setText(plugin)
item.setText(plugin.name)
if plugin in self.state.plugins:
item.setCheckState(Qt.Checked)
else:
@@ -353,17 +358,16 @@ class WizardInstallerCompletePage(QtWidgets.QWidget):
sp.append(item.text())
return sp
def plugins(self) -> List[str]:
def plugins(self) -> Dict[str, bool]:
"""
Returns:
The list of plugins selected in the UI (either automatically by the
interpreter or by the user).
"""
sp: List[str] = []
sp: Dict[str, bool] = {}
for i in range(self.ui.pluginsList.count()):
item = self.ui.pluginsList.item(i)
if item.checkState() == Qt.Checked:
sp.append(item.text())
sp[item.text()] = item.checkState() == Qt.Checked
return sp
def tweaks(self) -> Mapping[str, List[WizardINISetting]]:
@@ -524,7 +528,7 @@ class WizardInstallerDialog(QtWidgets.QDialog):
assert isinstance(widget, WizardInstallerCompletePage)
return widget.subpackages()
def plugins(self):
def plugins(self) -> Dict[str, bool]:
"""
Returns:
The list of plugins to install and enable. Only valid if exec() returned
@@ -543,7 +547,9 @@ class WizardInstallerDialog(QtWidgets.QDialog):
"""
widget = self.ui.stackedWidget.currentWidget()
assert isinstance(widget, WizardInstallerCompletePage)
return widget.state.renames
return {
plugin.name: new_name for plugin, new_name in widget.state.renames.items()
}
def tweaks(self) -> Mapping[str, List[WizardINISetting]]:
"""
@@ -624,13 +630,13 @@ class WizardInstallerDialog(QtWidgets.QDialog):
name: str = self.ui.nextBtn.text()
if isinstance(widget, WizardInstallerSelectPage):
name = self._tr("Next")
name = self.__tr("Next")
elif isinstance(widget, WizardInstallerRequiresVersionPage):
name = self._tr("Install anyway")
name = self.__tr("Install anyway")
elif isinstance(widget, (WizardInstallerCancelPage, WizardInstallerErrorPage)):
self.ui.nextBtn.setDisabled(True)
else:
name = self._tr("Install")
name = self.__tr("Install")
self.ui.nextBtn.setText(name)
@@ -683,5 +689,5 @@ class WizardInstallerDialog(QtWidgets.QDialog):
self._update_focus()
return super().exec()
def _tr(self, txt: str) -> str:
return QtWidgets.QApplication.translate("WizardInstaller", txt)
def __tr(self, str):
return QApplication.translate("WizardInstallerDialog", str)
+20 -11
View File
@@ -1,19 +1,17 @@
# -*- encoding: utf-8 -*-
import re
import os
import re
import sys
from collections import defaultdict
from pathlib import Path
from typing import Dict, Optional, List, Union
from typing import Dict, List, Optional, Union
import mobase
from PyQt5 import QtWidgets
# MO2 ships with PyQt5, so you can use it in your plugins:
from PyQt5.QtWidgets import QApplication
from PyQt5 import QtWidgets
import mobase
from wizard.runner import WizardRunnerState
from .dialog import WizardInstallerDialog
@@ -53,11 +51,14 @@ class WizardInstaller(mobase.IPluginInstallerSimple):
def name(self):
return "BAIN Wizard Installer"
def localizedName(self) -> str:
return self.__tr("BAIN Wizard Installer")
def author(self):
return "Holt59"
def description(self):
return self._tr("Installer for BAIN archive containing wizard scripts.")
return self.__tr("Installer for BAIN archive containing wizard scripts.")
def version(self):
return mobase.VersionInfo(1, 0, 2)
@@ -134,10 +135,10 @@ class WizardInstaller(mobase.IPluginInstallerSimple):
def _hasFomodInstaller(self) -> bool:
# Do not consider the NCC installer.
return bool(self._organizer.pluginSetting("Fomod Installer", "enabled"))
return self._organizer.isPluginEnabled("Fomod Installer")
def _hasOmodInstaller(self) -> bool:
return bool(self._organizer.pluginSetting("Omod Installer", "enabled"))
return self._organizer.isPluginEnabled("Omod Installer")
def _getWizardArchiveBase(
self, tree: mobase.IFileTree, data_name: str, checker: mobase.ModDataChecker
@@ -332,6 +333,14 @@ class WizardInstaller(mobase.IPluginInstallerSimple):
tree.move(entry, new)
# Move not selected plugins to optional:
for plugin, enabled in dialog.plugins().items():
if not enabled:
entry = tree.find(plugin)
if not entry:
continue # silently fail since the plugin should be disabled
tree.addDirectory("optional").insert(entry)
# TODO: INI Tweaks:
alltweaks = dialog.tweaks()
@@ -385,7 +394,7 @@ class WizardInstaller(mobase.IPluginInstallerSimple):
else:
return mobase.InstallResult.CANCELED
def _tr(self, str):
def __tr(self, str) -> str:
# We need this to translate string in Python. Check the common documentation
# for more details:
return QApplication.translate("WizardInstaller", str)
+26 -36
View File
@@ -1,12 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS><TS version="2.0">
<context>
<name>WizardInstallerComplete</name>
<name>WizardInstaller</name>
<message>
<location filename="ui/wizardinstallercomplete.ui" line="14"/>
<source>Form</source>
<location filename="installer.py" line="61"/>
<source>Installer for BAIN archive containing wizard scripts.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="installer.py" line="55"/>
<source>BAIN Wizard Installer</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>WizardInstallerComplete</name>
<message>
<location filename="ui/wizardinstallercomplete.ui" line="40"/>
<source>The installer script has finished. The following sub-packages and plugins will be installed.</source>
@@ -35,6 +43,21 @@
</context>
<context>
<name>WizardInstallerDialog</name>
<message>
<location filename="ui/wizardinstallerdialog.ui" line="102"/>
<source>Next</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="dialog.py" line="635"/>
<source>Install anyway</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="dialog.py" line="639"/>
<source>Install</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="ui/wizardinstallerdialog.ui" line="14"/>
<source>BAIN Wizard Installer</source>
@@ -60,42 +83,14 @@
<source>Back</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="ui/wizardinstallerdialog.ui" line="102"/>
<source>Next</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="ui/wizardinstallerdialog.ui" line="109"/>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>WizardInstallerError</name>
<message>
<location filename="ui/wizardinstallererror.ui" line="14"/>
<source>Form</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="ui/wizardinstallererror.ui" line="71"/>
<source>TextLabel</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>WizardInstallerPage</name>
<message>
<location filename="ui/wizardinstallerpage.ui" line="14"/>
<source>Form</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="ui/wizardinstallerpage.ui" line="96"/>
<source>TextLabel</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="ui/wizardinstallerpage.ui" line="114"/>
<source>Options:</source>
@@ -109,11 +104,6 @@
</context>
<context>
<name>WizardInstallerRequires</name>
<message>
<location filename="ui/wizardinstallerrequires.ui" line="14"/>
<source>Form</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="ui/wizardinstallerrequires.ui" line="34"/>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Warning:&lt;/span&gt; The following version requirements are not met for using this installer.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
+1 -3
View File
@@ -1,17 +1,15 @@
# -*- encoding: utf-8 -*-
import sys
from pathlib import Path
from typing import Iterable, List, Optional
import mobase
from wizard.interpreter import WizardInterpreter
from wizard.manager import ManagerModInterface
from wizard.severity import SeverityContext
from wizard.value import SubPackage, SubPackages
from wizard.utils import make_runner_context_factory
from wizard.value import SubPackage, SubPackages
class MO2SubPackage(SubPackage):
+1 -1
View File
@@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
<string notr="true"/>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="leftMargin">
+13 -3
View File
@@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
<string notr="true"/>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="leftMargin">
@@ -45,7 +45,7 @@
</size>
</property>
<property name="text">
<string>TextLabel</string>
<string notr="true"/>
</property>
</widget>
</item>
@@ -68,7 +68,7 @@
<item>
<widget class="QLabel" name="titleLabel">
<property name="text">
<string>TextLabel</string>
<string notr="true"/>
</property>
<property name="wordWrap">
<bool>true</bool>
@@ -82,6 +82,16 @@
<property name="readOnly">
<bool>true</bool>
</property>
<property name="markdown">
<string notr="true"/>
</property>
<property name="html">
<string notr="true">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
+2 -2
View File
@@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
<string notr="true"/>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="leftMargin">
@@ -93,7 +93,7 @@
<enum>QFrame::Sunken</enum>
</property>
<property name="text">
<string>TextLabel</string>
<string notr="true"/>
</property>
<property name="wordWrap">
<bool>true</bool>
+1 -1
View File
@@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
<string notr="true"/>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="leftMargin">
-1
View File
@@ -1,7 +1,6 @@
# -*- encoding: utf-8 -*-
import re
from pathlib import Path
from typing import Dict, List, Mapping