Files
Daniel Schlatter 48cddc62ba Make bg3 plugin more robust (#204)
* fix plugin icons not showing up when building with mob by embedding svgs instead
* gate yaml import in bg3_file_mapper to ensure its only imported if user is using the functionality
* bail out of mapping function early if modlist is empty
* ensure spacing is consistent in generated modsettings.xml by creating a function to share the creating of the xml strings for ModuleShortDesc
* dont do diffing if file doesnt exist or debug logging is not enabled
* ensure dialog boxes are exec'd so the user can see them
* mv log.txt files to logs dir, only make one logging statement for file moving
* remove empty folders left behind by plugin in documents dir when executable finishes, log folders removed
* add conversion of yamls in bin folder that wont get mapped to the documents directory
* ensure all directories are created when they are needed
* add catch for oserror in pak parsing function
* add a small sleep after creation of modsettings.xml to ensure the executable does not launch too fast to see it
* create directories that should be sent to overwrite folder from the documents folder if they dont exist in the mapping function, log all directories mapped if debug is enabled
2026-01-04 11:13:52 +01:00

50 lines
1.3 KiB
Python

from PyQt6.QtCore import QCoreApplication
from PyQt6.QtGui import QIcon, QPixmap
import mobase
class BG3ToolPlugin(mobase.IPluginTool, mobase.IPlugin):
desc = sub_name = ""
icon_bytes: bytes
def __init__(self):
mobase.IPluginTool.__init__(self)
mobase.IPlugin.__init__(self)
self._pluginName = self._displayName = "BG3 Tools"
self._pluginVersion = mobase.VersionInfo(1, 0, 0)
pixmap = QPixmap()
pixmap.loadFromData(self.icon_bytes, "SVG")
self.qicon = QIcon(pixmap)
def init(self, organizer: mobase.IOrganizer) -> bool:
self._organizer = organizer
return True
def version(self):
return self._pluginVersion
def author(self):
return "daescha"
def name(self):
return f"{self._pluginName}: {self.sub_name}"
def displayName(self):
return f"{self._displayName}/{self.sub_name}"
def tooltip(self):
return self.description()
def enabledByDefault(self):
return self._organizer.managedGame().name() == "Baldur's Gate 3 Plugin"
def settings(self) -> list[mobase.PluginSetting]:
return []
def icon(self) -> QIcon:
return self.qicon
def description(self) -> str:
return QCoreApplication.translate(self._pluginName, self.desc)