mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Extract plugins from settings.
There isn't really any need for these two types to interact. The lua plugin manager effectively fully owned its properties, it just delegated all reads and writes to the settings object. Instead, break the plugin settings out into the plugin manager and preserve the manager in the Game. This will make it possible to expose plugin options in the NGW without breaking the game on cancel.
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
"""Combo box for selecting a flight's task type."""
|
||||
|
||||
from PySide6.QtWidgets import QComboBox
|
||||
from game.ato.flighttype import FlightType
|
||||
from game.settings.settings import Settings
|
||||
|
||||
from game.ato.flighttype import FlightType
|
||||
from game.plugins import LuaPluginManager
|
||||
from game.theater import ConflictTheater, MissionTarget
|
||||
|
||||
|
||||
@@ -11,14 +11,18 @@ class QFlightTypeComboBox(QComboBox):
|
||||
"""Combo box for selecting a flight task type."""
|
||||
|
||||
def __init__(
|
||||
self, theater: ConflictTheater, target: MissionTarget, settings: Settings
|
||||
self,
|
||||
theater: ConflictTheater,
|
||||
target: MissionTarget,
|
||||
lua_plugin_manager: LuaPluginManager,
|
||||
) -> None:
|
||||
super().__init__()
|
||||
self.theater = theater
|
||||
self.target = target
|
||||
for mission_type in self.target.mission_types(for_player=True):
|
||||
if mission_type == FlightType.AIR_ASSAULT and not settings.plugin_option(
|
||||
"ctld"
|
||||
if (
|
||||
mission_type == FlightType.AIR_ASSAULT
|
||||
and not lua_plugin_manager.is_plugin_enabled("ctld")
|
||||
):
|
||||
# Only add Air Assault if ctld plugin is enabled
|
||||
continue
|
||||
|
||||
@@ -4,22 +4,22 @@ from PySide6.QtCore import Qt, Signal
|
||||
from PySide6.QtWidgets import (
|
||||
QComboBox,
|
||||
QDialog,
|
||||
QHBoxLayout,
|
||||
QLabel,
|
||||
QLineEdit,
|
||||
QMessageBox,
|
||||
QPushButton,
|
||||
QVBoxLayout,
|
||||
QLineEdit,
|
||||
QHBoxLayout,
|
||||
)
|
||||
from dcs.unittype import FlyingType
|
||||
|
||||
from game import Game
|
||||
from game.ato.flight import Flight
|
||||
from game.ato.flightroster import FlightRoster
|
||||
from game.ato.package import Package
|
||||
from game.ato.starttype import StartType
|
||||
from game.squadrons.squadron import Squadron
|
||||
from game.theater import ControlPoint, OffMapSpawn
|
||||
from game.ato.package import Package
|
||||
from game.ato.flightroster import FlightRoster
|
||||
from game.ato.flight import Flight
|
||||
from qt_ui.uiconstants import EVENT_ICONS
|
||||
from qt_ui.widgets.QFlightSizeSpinner import QFlightSizeSpinner
|
||||
from qt_ui.widgets.QLabeledWidget import QLabeledWidget
|
||||
@@ -51,7 +51,7 @@ class QFlightCreator(QDialog):
|
||||
layout = QVBoxLayout()
|
||||
|
||||
self.task_selector = QFlightTypeComboBox(
|
||||
self.game.theater, package.target, self.game.settings
|
||||
self.game.theater, package.target, self.game.lua_plugin_manager
|
||||
)
|
||||
self.task_selector.setCurrentIndex(0)
|
||||
self.task_selector.currentIndexChanged.connect(self.on_task_changed)
|
||||
|
||||
@@ -61,8 +61,9 @@ class QFlightWaypointTab(QFrame):
|
||||
self.recreate_buttons.clear()
|
||||
for task in self.package.target.mission_types(for_player=True):
|
||||
|
||||
if task == FlightType.AIR_ASSAULT and not self.game.settings.plugin_option(
|
||||
"ctld"
|
||||
if (
|
||||
task == FlightType.AIR_ASSAULT
|
||||
and not self.game.lua_plugin_manager.is_plugin_enabled("ctld")
|
||||
):
|
||||
# Only add Air Assault if ctld plugin is enabled
|
||||
continue
|
||||
|
||||
@@ -285,7 +285,7 @@ class QSettingsWindow(QDialog):
|
||||
self.categoryModel.appendRow(cheat)
|
||||
self.right_layout.addWidget(self.cheatPage)
|
||||
|
||||
self.pluginsPage = PluginsPage()
|
||||
self.pluginsPage = PluginsPage(self.game.lua_plugin_manager)
|
||||
plugins = QStandardItem("LUA Plugins")
|
||||
plugins.setIcon(CONST.ICONS["Plugins"])
|
||||
plugins.setEditable(False)
|
||||
@@ -293,7 +293,7 @@ class QSettingsWindow(QDialog):
|
||||
self.categoryModel.appendRow(plugins)
|
||||
self.right_layout.addWidget(self.pluginsPage)
|
||||
|
||||
self.pluginsOptionsPage = PluginOptionsPage()
|
||||
self.pluginsOptionsPage = PluginOptionsPage(self.game.lua_plugin_manager)
|
||||
pluginsOptions = QStandardItem("LUA Plugins Options")
|
||||
pluginsOptions.setIcon(CONST.ICONS["PluginsOptions"])
|
||||
pluginsOptions.setEditable(False)
|
||||
|
||||
@@ -12,14 +12,14 @@ from game.plugins import LuaPlugin, LuaPluginManager
|
||||
|
||||
|
||||
class PluginsBox(QGroupBox):
|
||||
def __init__(self) -> None:
|
||||
def __init__(self, manager: LuaPluginManager) -> None:
|
||||
super().__init__("Plugins")
|
||||
|
||||
layout = QGridLayout()
|
||||
layout.setAlignment(Qt.AlignTop)
|
||||
self.setLayout(layout)
|
||||
|
||||
for row, plugin in enumerate(LuaPluginManager.plugins()):
|
||||
for row, plugin in enumerate(manager.iter_plugins()):
|
||||
if not plugin.show_in_ui:
|
||||
continue
|
||||
|
||||
@@ -32,14 +32,14 @@ class PluginsBox(QGroupBox):
|
||||
|
||||
|
||||
class PluginsPage(QWidget):
|
||||
def __init__(self) -> None:
|
||||
def __init__(self, manager: LuaPluginManager) -> None:
|
||||
super().__init__()
|
||||
|
||||
layout = QVBoxLayout()
|
||||
layout.setAlignment(Qt.AlignTop)
|
||||
self.setLayout(layout)
|
||||
|
||||
layout.addWidget(PluginsBox())
|
||||
layout.addWidget(PluginsBox(manager))
|
||||
|
||||
|
||||
class PluginOptionsBox(QGroupBox):
|
||||
@@ -60,13 +60,13 @@ class PluginOptionsBox(QGroupBox):
|
||||
|
||||
|
||||
class PluginOptionsPage(QWidget):
|
||||
def __init__(self) -> None:
|
||||
def __init__(self, manager: LuaPluginManager) -> None:
|
||||
super().__init__()
|
||||
|
||||
layout = QVBoxLayout()
|
||||
layout.setAlignment(Qt.AlignTop)
|
||||
self.setLayout(layout)
|
||||
|
||||
for plugin in LuaPluginManager.plugins():
|
||||
for plugin in manager.iter_plugins():
|
||||
if plugin.options:
|
||||
layout.addWidget(PluginOptionsBox(plugin))
|
||||
|
||||
Reference in New Issue
Block a user